tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r413315 - /tomcat/container/branches/tc4.1.x/catalina/src/share/org/apache/catalina/startup/ExpandWar.java
Date Sat, 10 Jun 2006 15:07:13 GMT
Author: markt
Date: Sat Jun 10 08:07:13 2006
New Revision: 413315

URL: http://svn.apache.org/viewvc?rev=413315&view=rev
Log:
Port fixes from 5.5.x
 - Bug 33636. Files now retain last modified time
 - Expanded wars closed so they can be deleted on remove

Modified:
    tomcat/container/branches/tc4.1.x/catalina/src/share/org/apache/catalina/startup/ExpandWar.java

Modified: tomcat/container/branches/tc4.1.x/catalina/src/share/org/apache/catalina/startup/ExpandWar.java
URL: http://svn.apache.org/viewvc/tomcat/container/branches/tc4.1.x/catalina/src/share/org/apache/catalina/startup/ExpandWar.java?rev=413315&r1=413314&r2=413315&view=diff
==============================================================================
--- tomcat/container/branches/tc4.1.x/catalina/src/share/org/apache/catalina/startup/ExpandWar.java
(original)
+++ tomcat/container/branches/tc4.1.x/catalina/src/share/org/apache/catalina/startup/ExpandWar.java
Sat Jun 10 08:07:13 2006
@@ -176,13 +176,16 @@
                     logger.log("  Creating expanded file " + name);
                 }
                 input = jarFile.getInputStream(jarEntry);
-                expand(input, docBase, name);
+                
+                File expandedFile = expand(input, docBase, name);
+                long lastModified = jarEntry.getTime();
+                if ((lastModified != -1) && (lastModified != 0) && (expandedFile
!= null)) {
+                    expandedFile.setLastModified(lastModified);
+                }
+
                 input.close();
                 input = null;
             }
-            // FIXME - Closing the JAR file messes up the class loader???
-            //            jarFile.close();
-            jarFile = null;
         } finally {
             if (input != null) {
                 try {
@@ -214,23 +217,36 @@
      * @param input InputStream to be copied
      * @param docBase Document base directory into which we are expanding
      * @param name Relative pathname of the file to be created
+     * @return A handle to the expanded File
      *
      * @exception IOException if an input/output error occurs
      */
-    protected static void expand(InputStream input, File docBase, String name)
+    protected static File expand(InputStream input, File docBase, String name)
         throws IOException {
 
         File file = new File(docBase, name);
-        BufferedOutputStream output =
-            new BufferedOutputStream(new FileOutputStream(file));
-        byte buffer[] = new byte[2048];
-        while (true) {
-            int n = input.read(buffer);
-            if (n <= 0)
-                break;
-            output.write(buffer, 0, n);
+        BufferedOutputStream output = null;
+        try {
+            output = 
+                new BufferedOutputStream(new FileOutputStream(file));
+            byte buffer[] = new byte[2048];
+            while (true) {
+                int n = input.read(buffer);
+                if (n <= 0)
+                    break;
+                output.write(buffer, 0, n);
+            }
+        } finally {
+            if (output != null) {
+                try {
+                    output.close();
+                } catch (IOException e) {
+                    // Ignore
+                }
+            }
         }
-        output.close();
+
+        return file;
 
     }
 



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


Mime
View raw message