Author: violetagg
Date: Fri Mar 15 15:07:15 2013
New Revision: 1456982

URL: http://svn.apache.org/r1456982
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=54702
Merged revision 1456959 from tomcat/trunk:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=54702
Close the stream at the end of the parse operation.

Modified:
    tomcat/tc7.0.x/trunk/   (props changed)
    tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java
    tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml

Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
  Merged /tomcat/trunk:r1456959

Modified: 
tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java?rev=1456982&r1=1456981&r2=1456982&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java 
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/startup/ContextConfig.java 
Fri Mar 15 15:07:15 2013
@@ -1850,6 +1850,17 @@ public class ContextConfig implements Li
     }
 
 
+    /**
+     * Parses the given source and stores the parsed data in the given web.xml
+     * representation. The byte stream will be closed at the end of the parse
+     * operation.
+     *
+     * @param source Input source containing the XML data to be parsed
+     * @param dest The object representation of common elements of web.xml and
+     *             web-fragment.xml
+     * @param fragment Specifies whether the source is web-fragment.xml or
+     *                 web.xml
+     */
     protected void parseWebXml(InputSource source, WebXml dest,
             boolean fragment) {
 
@@ -1897,6 +1908,15 @@ public class ContextConfig implements Li
         } finally {
             digester.reset();
             ruleSet.recycle();
+
+            InputStream is = source.getByteStream();
+            if (is != null) {
+                try {
+                    is.close();
+                } catch (Throwable t) {
+                    ExceptionUtils.handleThrowable(t);
+                }
+            }
         }
     }
 
@@ -2662,13 +2682,6 @@ public class ContextConfig implements Li
                     parseWebXml(source, fragment, true);
                 }
             } finally {
-                if (is != null) {
-                    try {
-                        is.close();
-                    } catch (IOException ioe) {
-                        // Ignore
-                    }
-                }
                 if (jar != null) {
                     jar.close();
                 }
@@ -2708,13 +2721,6 @@ public class ContextConfig implements Li
                     parseWebXml(source, fragment, true);
                 }
             } finally {
-                if (stream != null) {
-                    try {
-                        stream.close();
-                    } catch (Throwable t) {
-                        ExceptionUtils.handleThrowable(t);
-                    }
-                }
                 fragment.setURL(file.toURI().toURL());
                 if (fragment.getName() == null) {
                     fragment.setName(fragment.getURL().toString());

Modified: tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
URL: 
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml?rev=1456982&r1=1456981&r2=1456982&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Fri Mar 15 15:07:15 2013
@@ -82,6 +82,11 @@
         revision 1456918 and the associated extract from Commons IO to 2.4.
         (markt)
       </update>
+      <fix>
+        <bug>54702</bug>: Prevent file descriptors leak and ensure that files
+        are closed when parsing web application deployment descriptors.
+        (violetagg)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to