Bug 52731 - An incomplete fix for the resource leak bug in JDTCompiler.java
An incomplete fix for the resource leak bug in JDTCompiler.java
Status: RESOLVED FIXED
Product: Tomcat 7
Classification: Unclassified
Component: Jasper
trunk
PC All
: P2 enhancement (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2012-02-21 12:16 UTC by lianggt08
Modified: 2012-03-06 22:40 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description lianggt08 2012-02-21 12:16:28 UTC
The fix revision 1043157 was aimed to remove an resource leak bug on the BufferedReader object "reader " (created in line 115), the FileInputStream object "is" (created in line 112) in the method "getContents()" of the file "/tomcat/trunk/java/org/apache/jasper/compiler/JDTCompiler.java" , but it is incomplete. 

There are some problems: 
1. when "reader" is not created successfully but the temp InputStreamReader is created successfully at line 114, the temp InputStreamReader will be leaked. 


The best way to close such resource objects is putting such close operations in the finaly block of a try-catch-finally structure.
Comment 1 Mark Thomas 2012-03-06 22:40:57 UTC
The failures that might trigger this issue are either an UnsupportedEncodingException in which case JSP compilation would be completely broken (and a much bigger issue that any resource leak) or the sort of error (e.g. OOME) that is far more serious than the resource leak and is likely to cause the JVM to terminate anyway.

Over all, not a critical issue. More like an enhancement request to clean up the code.

Fixed in trunk and 7.0.x and will be included in 7.0.27 onwards.