tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r490148 - in /tomcat/container/tc5.5.x: catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java webapps/docs/changelog.xml
Date Mon, 25 Dec 2006 13:31:08 GMT
Author: yoavs
Date: Mon Dec 25 05:31:07 2006
New Revision: 490148

URL: http://svn.apache.org/viewvc?view=rev&rev=490148
Log:
Bugzilla 40326: don't use File#deleteOnExit in DefaultServlet.

Modified:
    tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java
    tomcat/container/tc5.5.x/webapps/docs/changelog.xml

Modified: tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java?view=diff&rev=490148&r1=490147&r2=490148
==============================================================================
--- tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java
(original)
+++ tomcat/container/tc5.5.x/catalina/src/share/org/apache/catalina/servlets/DefaultServlet.java
Mon Dec 25 05:31:07 2006
@@ -459,6 +459,15 @@
             result = false;
         }
 
+        // Bugzilla 40326: at this point content file should be safe to delete
+        // as it's no longer referenced.  Let's not rely on deleteOnExit because
+        // it's a memory leak, as noted in this Bugzilla issue.
+        try {
+            contentFile.delete();
+        } catch (Exception e) {
+            log("DefaultServlet.doPut: couldn't delete temporary file: " + e.getMessage());
+        }
+
         if (result) {
             if (exists) {
                 resp.setStatus(HttpServletResponse.SC_NO_CONTENT);
@@ -489,10 +498,7 @@
         // Convert all '/' characters to '.' in resourcePath
         String convertedResourcePath = path.replace('/', '.');
         File contentFile = new File(tempDir, convertedResourcePath);
-        if (contentFile.createNewFile()) {
-            // Clean up contentFile when Tomcat is terminated
-            contentFile.deleteOnExit();
-        }
+        contentFile.createNewFile();
 
         RandomAccessFile randAccessContentFile =
             new RandomAccessFile(contentFile, "rw");
@@ -503,6 +509,7 @@
             if (obj instanceof Resource)
                 oldResource = (Resource) obj;
         } catch (NamingException e) {
+            log("DefaultServlet.executePartialPut: couldn't find resource at " + path);
         }
 
         // Copy data in oldRevisionContent to contentFile

Modified: tomcat/container/tc5.5.x/webapps/docs/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/webapps/docs/changelog.xml?view=diff&rev=490148&r1=490147&r2=490148
==============================================================================
--- tomcat/container/tc5.5.x/webapps/docs/changelog.xml (original)
+++ tomcat/container/tc5.5.x/webapps/docs/changelog.xml Mon Dec 25 05:31:07 2006
@@ -168,6 +168,10 @@
         <bug>39476</bug>: add xml declaration to most build.xml files, as suggested
by
         Gregory S. Hoerner Sr. (yoavs)
       </update>
+      <fix>
+        <bug>40326</bug>: : stop using File#deleteOnExit in DefaultServlet to
avoid
+        JVM memory leak, as suggested by quartz. (yoavs)
+      </fix>
     </changelog>
   </subsection> 
   <subsection name="Coyote">



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


Mime
View raw message