You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2015/03/04 22:00:50 UTC

svn commit: r1664143 - /tomcat/trunk/java/org/apache/catalina/startup/ExpandWar.java

Author: markt
Date: Wed Mar  4 21:00:49 2015
New Revision: 1664143

URL: http://svn.apache.org/r1664143
Log:
Fix file leak. Need to make sure the JarURLConnection is explicitly closed. Leaving it to GC will cause random file locking.

Modified:
    tomcat/trunk/java/org/apache/catalina/startup/ExpandWar.java

Modified: tomcat/trunk/java/org/apache/catalina/startup/ExpandWar.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/catalina/startup/ExpandWar.java?rev=1664143&r1=1664142&r2=1664143&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/catalina/startup/ExpandWar.java (original)
+++ tomcat/trunk/java/org/apache/catalina/startup/ExpandWar.java Wed Mar  4 21:00:49 2015
@@ -73,7 +73,7 @@ public class ExpandWar {
         throws IOException {
 
         // Open the connection to the WAR. There is no explicit close method.
-        // You have to get the JarFile and close that.
+        // You have to get the InputStream and close that.
         JarURLConnection juc = (JarURLConnection) war.openConnection();
         juc.setUseCaches(false);
 
@@ -82,7 +82,8 @@ public class ExpandWar {
         File docBase = new File(host.getAppBaseFile(), pathname);
         File warTracker = new File(host.getAppBaseFile(), pathname + Constants.WarTracker);
 
-        try (JarFile jarFile = juc.getJarFile()) {
+        try (JarFile jarFile = juc.getJarFile();
+                InputStream is = juc.getInputStream()) {
 
             // Get the last modified time for the WAR
             long warLastModified = juc.getLastModified();



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


Re: svn commit: r1664143 - /tomcat/trunk/java/org/apache/catalina/startup/ExpandWar.java

Posted by Mark Thomas <ma...@apache.org>.
On 04/03/2015 21:00, markt@apache.org wrote:
> Author: markt
> Date: Wed Mar  4 21:00:49 2015
> New Revision: 1664143
> 
> URL: http://svn.apache.org/r1664143
> Log:
> Fix file leak. Need to make sure the JarURLConnection is explicitly closed. Leaving it to GC will cause random file locking.

Bah.

This fixes the leak but it creates a different problem. I'm working on
the fix.

Mark


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