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);
}
}

This is ASF Bugzilla: the Apache Software Foundation bug system. In case
of problems with the functioning of ASF Bugzilla, please contact
bugzilla-admin@apache.org.
Please Note: this e-mail address is only for reporting problems
with ASF Bugzilla. Mail about any other subject will be silently
ignored.