You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Bill Hayden <bh...@efficient.com> on 2001/01/11 20:50:10 UTC

PATCH

In developing a servlet, I came across a bug in the tomcat code. The problem
was that the server was leaking file handle resources. I could run my
servlet a couple of times, but then it would cause an OutOf Memory
exception. The problem was in the (partial path here)
org/apache/tomcat/loader/AdaptiveClassLoader.java class. Specifically, in
the getResource(String name) method, a ZipFile object is instantiated. This
opens a zip file. The file is never closed. A source code snippet follows
with the fix in bold: 
   // a jar:-URL *could* change even between minor releases, but 
   // didn't between JVM's 1.1.6 and 1.3beta. Tested on JVM's from 
   // IBM, Blackdown, Microsoft, Sun @ Windows and Sun @ Solaris 
   try { 
   ZipFile zf = new ZipFile(file.getAbsolutePath()); 
   ZipEntry ze = zf.getEntry(name); 

   zf.close() ; 
   if (ze != null) { 

A small oversight, but this was a show stopper for me. I'm happy to
contribute something back for the use of this software. 
Kindest regards, 
William D. Hayden