The fix for bug 51310 caused a regression that re-introduced bug 49957 and deleted...
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 20 Jun 2011 16:38:40 +0000 (16:38 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Mon, 20 Jun 2011 16:38:40 +0000 (16:38 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1137693 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/startup/ContextConfig.java
webapps/docs/changelog.xml

index b6d406c..550b771 100644 (file)
@@ -58,6 +58,8 @@ import org.apache.catalina.Lifecycle;
 import org.apache.catalina.LifecycleEvent;
 import org.apache.catalina.LifecycleListener;
 import org.apache.catalina.Pipeline;
+import org.apache.catalina.Server;
+import org.apache.catalina.Service;
 import org.apache.catalina.Valve;
 import org.apache.catalina.Wrapper;
 import org.apache.catalina.core.ContainerBase;
@@ -1090,6 +1092,12 @@ public class ContextConfig
         if (log.isDebugEnabled())
             log.debug(sm.getString("contextConfig.destroy"));
 
+        // Skip clearing the work directory if Tomcat is being shutdown
+        Server s = getServer();
+        if (s != null && !s.getState().isAvailable()) {
+            return;
+        }
+        
         // Changed to getWorkPath per Bugzilla 35819.
         String workDir = ((StandardContext) context).getWorkPath();
         if (workDir != null)
@@ -1097,6 +1105,25 @@ public class ContextConfig
     }
     
     
+    private Server getServer() {
+        Container c = context;
+        while (c != null && !(c instanceof Engine)) {
+            c = c.getParent();
+        }
+        
+        if (c == null) {
+            return null;
+        }
+        
+        Service s = ((Engine)c).getService();
+        
+        if (s == null) {
+            return null;
+        }
+        
+        return s.getServer();
+    }
+
     /**
      * Validate the usage of security role names in the web application
      * deployment descriptor.  If any problems are found, issue warning
index 55d0eb5..aa7eb27 100644 (file)
         Add the Tomcat extras JARs to the list of JARs to skip when scanning
         for TLDs and web fragments. (rjung)
       </update>
+      <fix>
+        The fix for bug <bug>51310</bug> caused a regression that re-introduced
+        bug <bug>49957</bug> and deleted the contents of the work directory
+        when Tomcat was shutdown. This fix ensures that that work directory for
+        an application is not deleted when Tomcat is shutdown. (mark)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">