https://issues.apache.org/bugzilla/show_bug.cgi?id=52742

             Bug #: 52742
           Summary: An incomplete fix for the resource leak bug in
                    Replace.java
           Product: Ant
           Version: unspecified
          Platform: PC
            Status: NEW
          Severity: critical
          Priority: P2
         Component: Core
        AssignedTo: [email protected]
        ReportedBy: [email protected]
    Classification: Unclassified


The fix revision 269961 was aimed to remove resource leak bugs on the
InputStreamReader object "reader" (created in line 314), the OutputStreamWriter
object (line 316) in the method "processFile"of the file
"/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/Replace.java" , but 
it is incomplete.

There are some problems: 
1. when "reader" isn't created successfully but the temp FileInputStream object
is created successfully (at line 315), the temp FileInputStream object will be
leaked. 
2. when "writer" isn't created successfully but the temp FileOutputStream
object is created successfully (at line 316), the temp FileOutputStream object
will be leaked. 
3. when the statements at lines 327-367 throw some exception, "bw" will be
leaked;
4. when the statements at lines 327-367 throw some exception, "br" 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 in the head revision.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

Reply via email to