Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=47343
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 11 Jun 2009 13:48:42 +0000 (13:48 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Thu, 11 Jun 2009 13:48:42 +0000 (13:48 +0000)
Regression in https://issues.apache.org/bugzilla/show_bug.cgi?id=42747
context.xml can now be edited without resources being deleted

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@783766 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/startup/HostConfig.java

index 66cd963..ec80600 100644 (file)
@@ -835,8 +835,6 @@ public class HostConfig
                     }
                 }
                 context.setConfigFile(xml.getAbsolutePath());
-                deployedApp.redeployResources.put
-                    (xml.getAbsolutePath(), new Long(xml.lastModified()));
             } else {
                 context = (Context) Class.forName(contextClass).newInstance();
             }
@@ -845,6 +843,11 @@ public class HostConfig
             deployedApp.redeployResources.put
                 (war.getAbsolutePath(), new Long(war.lastModified()));
 
+            if (deployXML && xml.exists()) {
+                deployedApp.redeployResources.put
+                (xml.getAbsolutePath(), new Long(xml.lastModified()));
+            }
+
             if (context instanceof Lifecycle) {
                 Class<?> clazz = Class.forName(host.getConfigClass());
                 LifecycleListener listener =
@@ -938,6 +941,7 @@ public class HostConfig
         try {
             Context context = null;
             File xml = new File(dir, Constants.ApplicationContextXml);
+            File xmlCopy = null;
             if (deployXML && xml.exists()) {
                 // Will only do this on initial deployment. On subsequent
                 // deployments the copied xml file means we'll use
@@ -954,7 +958,7 @@ public class HostConfig
                         digester.reset();
                     }
                 }
-                File xmlCopy = new File(configBase(), file + ".xml");
+                xmlCopy = new File(configBase(), file + ".xml");
                 InputStream is = null;
                 OutputStream os = null;
                 try {
@@ -975,8 +979,6 @@ public class HostConfig
                     }
                 }
                 context.setConfigFile(xmlCopy.getAbsolutePath());
-                deployedApp.redeployResources.put
-                    (xmlCopy.getAbsolutePath(), new Long(xmlCopy.lastModified()));
             } else {
                 context = (Context) Class.forName(contextClass).newInstance();
             }
@@ -992,6 +994,10 @@ public class HostConfig
             host.addChild(context);
             deployedApp.redeployResources.put(dir.getAbsolutePath(),
                     new Long(dir.lastModified()));
+            if (xmlCopy != null) {
+                deployedApp.redeployResources.put
+                (xmlCopy.getAbsolutePath(), new Long(xmlCopy.lastModified()));
+            }
             addWatchedResources(deployedApp, dir.getAbsolutePath(), context);
         } catch (Throwable t) {
             log.error(sm.getString("hostConfig.deployDir.error", file), t);