tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 52721] New: An incomplete fix for the resource leak bug in StandardContext.java
Date Tue, 21 Feb 2012 10:00:19 GMT
https://issues.apache.org/bugzilla/show_bug.cgi?id=52721

             Bug #: 52721
           Summary: An incomplete fix for the resource leak bug in
                    StandardContext.java
           Product: Tomcat 6
           Version: unspecified
          Platform: PC
            Status: NEW
          Severity: critical
          Priority: P2
         Component: Catalina
        AssignedTo: dev@tomcat.apache.org
        ReportedBy: lianggt08@sei.pku.edu.cn
    Classification: Unclassified


The fix revision 423920 was aimed to remove an resource leak bug on the 
FileOutputStream object "fos"and the ObjectOutputStream "oos"  in the method
"cacheContext" of the file
"/tomcat/tc6.0.x/trunk/java/org/apache/catalina/core/StandardContext.java" ,
but it is incomplete. 

When the statements at lines 4792 throw any eception, the objects "fos" and
"oos" can not be closed as expected. The best way to close such resource object
is putting such close operations in the finaly block of a try-catch-finally
structure.

Besides that, when oos is created unsuccessfully but "fos"  is created
successfully,  "fos" will also be leaked. 


The buggy code in the head revision is copied as bellows:


 private void cacheContext() {
        try {
            File workDir=new File( getWorkPath() );

            File ctxSer=new File( workDir, "_tomcat_context.ser");
            FileOutputStream fos=new FileOutputStream( ctxSer );
            ObjectOutputStream oos=new ObjectOutputStream( fos );
            oos.writeObject(this);
[line 4793]            oos.close();
[line 4794]            fos.close();
        } catch( Throwable t ) {
            if(log.isInfoEnabled())
                log.info("Error saving context.ser ", t);
        }
    }

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

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message