Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=50460
authorkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 13 Dec 2010 00:58:11 +0000 (00:58 +0000)
committerkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 13 Dec 2010 00:58:11 +0000 (00:58 +0000)
Avoid leak caused by using a cached exception instance

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1044987 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/jasper/compiler/JspDocumentParser.java
java/org/apache/naming/resources/ImmutableNameNotFoundException.java

index f5edf7e..ef6ba2e 100644 (file)
@@ -58,11 +58,6 @@ class JspDocumentParser
         "http://xml.org/sax/properties/lexical-handler";
     private static final String JSP_URI = "http://java.sun.com/JSP/Page";
 
-    private static final EnableDTDValidationException ENABLE_DTD_VALIDATION_EXCEPTION =
-        new EnableDTDValidationException(
-            "jsp.error.enable_dtd_validation",
-            null);
-
     private ParserController parserController;
     private JspCompilationContext ctxt;
     private PageInfo pageInfo;
@@ -757,7 +752,8 @@ class JspDocumentParser
     public void startDTD(String name, String publicId, String systemId)
         throws SAXException {
         if (!isValidating) {
-            fatalError(ENABLE_DTD_VALIDATION_EXCEPTION);
+            fatalError(new EnableDTDValidationException(
+                    "jsp.error.enable_dtd_validation", null));
         }
 
         inDTD = true;
@@ -1459,6 +1455,12 @@ class JspDocumentParser
         EnableDTDValidationException(String message, Locator loc) {
             super(message, loc);
         }
+
+        @Override
+        public synchronized Throwable fillInStackTrace() {
+            // This class does not provide a stack trace
+            return this;
+        }
     }
 
     private static String getBodyType(Node.CustomTag custom) {
index f7481ab..ceec12c 100644 (file)
@@ -44,4 +44,9 @@ public class ImmutableNameNotFoundException
     @Override
     public void setRootCause(Throwable e) {/*NOOP*/}
 
+    @Override
+    public synchronized Throwable fillInStackTrace() {
+        // This class does not provide a stack trace
+        return this;
+    }
 }