Author: violetagg
Date: Wed Sep 3 14:27:20 2014
New Revision: 1622270
URL: http://svn.apache.org/r1622270
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56902
Merged revision 1621729 from tomcat/trunk:
Potential resource leak in Default Servlet
Based on a patch by Felix Schumacher
Modified:
tomcat/tc7.0.x/trunk/ (props changed)
tomcat/tc7.0.x/trunk/java/org/apache/catalina/servlets/DefaultServlet.java
tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml
Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
Merged /tomcat/trunk:r1621729
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/catalina/servlets/DefaultServlet.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/catalina/servlets/DefaultServlet.java?rev=1622270&r1=1622269&r2=1622270&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/catalina/servlets/DefaultServlet.java
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/catalina/servlets/DefaultServlet.java
Wed Sep 3 14:27:20 2014
@@ -2128,27 +2128,32 @@ public class DefaultServlet
while ( (exception == null) && (ranges.hasNext()) ) {
InputStream resourceInputStream =
cacheEntry.resource.streamContent();
- InputStream istream =
- new BufferedInputStream(resourceInputStream, input);
-
- Range currentRange = ranges.next();
-
- // Writing MIME header.
- ostream.println();
- ostream.println("--" + mimeSeparation);
- if (contentType != null)
- ostream.println("Content-Type: " + contentType);
- ostream.println("Content-Range: bytes " + currentRange.start
- + "-" + currentRange.end + "/"
- + currentRange.length);
- ostream.println();
-
- // Printing content
- exception = copyRange(istream, ostream, currentRange.start,
- currentRange.end);
-
- istream.close();
+ InputStream istream = null;
+ try {
+ istream = new BufferedInputStream(resourceInputStream, input);
+ Range currentRange = ranges.next();
+ // Writing MIME header.
+ ostream.println();
+ ostream.println("--" + mimeSeparation);
+ if (contentType != null)
+ ostream.println("Content-Type: " + contentType);
+ ostream.println("Content-Range: bytes " + currentRange.start
+ + "-" + currentRange.end + "/"
+ + currentRange.length);
+ ostream.println();
+
+ // Printing content
+ exception = copyRange(istream, ostream, currentRange.start,
+ currentRange.end);
+ } finally {
+ if (istream != null) {
+ try {
+ istream.close();
+ } catch (IOException e) {
+ }
+ }
+ }
}
ostream.println();
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=1622270&r1=1622269&r2=1622270&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/tc7.0.x/trunk/webapps/docs/changelog.xml Wed Sep 3 14:27:20 2014
@@ -107,6 +107,11 @@
when Context have been reloaded. (kkolinko)
</scode>
<fix>
+ <bug>56902</bug>: Fix a potential resource leak in the Default Servlet
+ reported by Coverity Scan. Based on a patch provided by Felix
+ Schumacher. (markt)
+ </fix>
+ <fix>
<bug>56903</bug>: Correct the return value for
<code>StandardContext.getResourceOnlyServlets()</code> so that multiple
names are separated by commas. Identified by Coverity Scan and fixed
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]