http://nagoya.apache.org/bugzilla/show_bug.cgi?id=316 *** shadow/316 Fri Mar 9 21:32:06 2001 --- shadow/316.tmp.13617 Fri Mar 9 21:32:07 2001 *************** *** 0 **** --- 1,52 ---- + +============================================================================+ + | AdaptiveClassLoader leaks file descriptors BugRat Report#575 | + +----------------------------------------------------------------------------+ + | Bug #: 316 Product: Tomcat 3 | + | Status: UNCONFIRMED Version: 3.2.1 Final | + | Resolution: Platform: All | + | Severity: Normal OS/Version: All | + | Priority: High Component: Servlet | + +----------------------------------------------------------------------------+ + | Assigned To: [EMAIL PROTECTED] | + | Reported By: [EMAIL PROTECTED] | + | CC list: Cc: | + +----------------------------------------------------------------------------+ + | URL: | + +============================================================================+ + | DESCRIPTION | + Under JDK 1.1.8, the AdaptiveClassLoader leaks file + descriptors from the getResource method. This gets invoked + ( among other times ) every time Beans.instantiate is called + with the servlet classloader instead of null ( it tries to + find a serialized bean before creating a default instance ). + The ZipFile object used to look in jars found in the + repository list is never explicitly closed ( and the finalize + method doesn't seem to do it either ). The solution is + to close the ZipFile in a finally block. Each time this + method runs and searches a zip file ( or jar ), it will leak + one file descriptor for each file it processes ( we have 10 + jars in our WEB-INF/lib so that's 10 file descriptors for + each hit to a page with one jsp:useBean ). A patch follows: + + --- jakarta-tomcat-3.2.orig/src/org/apache/tomcat/loader/AdaptiveClassLoader.java + Wed Nov 29 20:47:52 2000 + +++ jakarta-tomcat-3.2/src/org/apache/tomcat/loader/AdaptiveClassLoader.java Tue +Dec 12 13:47:05 2000 + @@ -804,8 +804,9 @@ + // 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 + + ZipFile zf = null; + try { + - ZipFile zf = new ZipFile(file.getAbsolutePath()); + + zf = new ZipFile(file.getAbsolutePath()); + ZipEntry ze = zf.getEntry(name); + + if (ze != null) { + @@ -819,6 +820,8 @@ + } catch (IOException ioe) { + ioe.printStackTrace(); + return null; + + } finally { + + if ( zf != null ) try { zf.close(); } catch ( IOException e ) { +} + } + } + } --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]