ASF Bugzilla – Attachment 31955 Details for
Bug 56902
DefaultServlet could leak resource in method copy - CID-45243
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
always close istream in DefaultServlet#copy
0001-Always-close-istream-even-when-an-exception-is-throw.patch (text/plain), 2.33 KB, created by
Felix Schumacher
on 2014-08-31 10:38:31 UTC
(
hide
)
Description:
always close istream in DefaultServlet#copy
Filename:
MIME Type:
Creator:
Felix Schumacher
Created:
2014-08-31 10:38:31 UTC
Size:
2.33 KB
patch
obsolete
>From 84b7e92c8e4247533fed61353bb9d9f1145c5bfb Mon Sep 17 00:00:00 2001 >From: Felix Schumacher <felix.schumacher@internetallee.de> >Date: Sun, 31 Aug 2014 12:29:22 +0200 >Subject: [PATCH] Always close istream, even when an exception is thrown while > writing to ostream. > >--- > .../apache/catalina/servlets/DefaultServlet.java | 36 ++++++++++++---------- > 1 file changed, 19 insertions(+), 17 deletions(-) > >diff --git a/java/org/apache/catalina/servlets/DefaultServlet.java b/java/org/apache/catalina/servlets/DefaultServlet.java >index a88f17d..584bff6 100644 >--- a/java/org/apache/catalina/servlets/DefaultServlet.java >+++ b/java/org/apache/catalina/servlets/DefaultServlet.java >@@ -2035,23 +2035,25 @@ public class DefaultServlet extends HttpServlet { > 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(); >+ try { >+ 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 { >+ istream.close(); >+ } > > } > >-- >1.9.1 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 56902
: 31955