Bug 52743 - An incomplete fix for the resource leak bug in ReplaceRegExp.java
An incomplete fix for the resource leak bug in ReplaceRegExp.java
Status: RESOLVED FIXED
Product: Ant
Classification: Unclassified
Component: Core
unspecified
All All
: P2 minor (vote)
: 1.9.0
Assigned To: Ant Notifications List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2012-02-23 08:40 UTC by lianggt08
Modified: 2012-03-05 16:51 UTC (History)
1 user (show)



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description lianggt08 2012-02-23 08:40:20 UTC
The fix revisions 270637, 272826, and 905179 were aimed to remove resource leak bugs on the Reader object "r", the Writer object "w", the BufferedWriter object "bw" in the method "doReplace"of the file "/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/ReplaceRegExp.java" , but it is incomplete.

In the head revision (rev1037691), there is still some problem: 
1. the BufferedReader object "br" created at line 369 isn't closed, and  it will be leaked. 

The best way to close such resource objects is putting such close operations for all resource objects in the finaly block of a try-catch-finally structure and then putting all other code in a try block.

The problem still exists.
Comment 1 Jesse Glick 2012-02-28 18:54:39 UTC
Committed revision 1294780.
Comment 2 Jesse Glick 2012-03-05 16:51:31 UTC
Refined in revision 1297127.