Bug 56902 - DefaultServlet could leak resource in method copy - CID-45243
Summary: DefaultServlet could leak resource in method copy - CID-45243
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 8.0.x-trunk
Hardware: All All
: P2 minor (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-08-31 10:38 UTC by Felix Schumacher
Modified: 2014-09-03 15:46 UTC (History)
0 users



Attachments
always close istream in DefaultServlet#copy (2.33 KB, patch)
2014-08-31 10:38 UTC, Felix Schumacher
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Felix Schumacher 2014-08-31 10:38:31 UTC
Created attachment 31955 [details]
always close istream in DefaultServlet#copy

In method copy istream could be left unclosed, if write operations on ostream would throw an exception before copyRange is called.

A simple fix is to wrap the ostream-operations together with copyRange in a try-finally block.

If the exceptions should be catched into the variable exception like copyRange does, it could be done so in an additionally catch block (which is missing from the attached patch).
Comment 1 Mark Thomas 2014-09-01 10:15:31 UTC
Thanks for reviewing the Coverity Scan results. I've applied a variation of your patch (I used try with resources) to 8.0.x and this will be included in 8.0.13 onwards.
Comment 2 Violeta Georgieva 2014-09-03 15:46:18 UTC
Fix is committed to 7.0.x and will be available in 7.0.56 onwards.