This is an automated email from the ASF dual-hosted git repository.

markt-asf pushed a commit to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/10.1.x by this push:
     new 35d449d45e Follow-on to antiResourceLocking improvements
35d449d45e is described below

commit 35d449d45e3a46b8460fcbb9dfc6f45304f89e71
Author: Mark Thomas <[email protected]>
AuthorDate: Fri Jun 26 21:16:34 2026 +0100

    Follow-on to antiResourceLocking improvements
---
 java/org/apache/catalina/startup/ContextConfig.java | 10 ++++------
 java/org/apache/catalina/startup/ExpandWar.java     |  2 +-
 webapps/docs/config/context.xml                     |  6 ++++++
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/java/org/apache/catalina/startup/ContextConfig.java 
b/java/org/apache/catalina/startup/ContextConfig.java
index 0f72ef792b..5d327663c9 100644
--- a/java/org/apache/catalina/startup/ContextConfig.java
+++ b/java/org/apache/catalina/startup/ContextConfig.java
@@ -213,8 +213,8 @@ public class ContextConfig implements LifecycleListener {
 
 
     /**
-     * Anti-locking docBase. It is a path to a copy of the web application in 
the java.io.tmpdir directory. This path is
-     * always an absolute one.
+     * Anti-locking docBase. This is a path to a copy of the web application 
located in a temporary directory under the
+     * default JVM temporary directory. This path is always an absolute one.
      */
     private File antiLockingDocBase = null;
 
@@ -968,8 +968,8 @@ public class ContextConfig implements LifecycleListener {
                 } else {
                     antiLockingDocBase = 
Files.createTempDirectory(prefix).toFile();
                 }
-            } catch (IOException ioe) {
-                log.error(sm.getString("contextConfig.noAntiLocking", 
context.getName()), ioe);
+            } catch (IllegalArgumentException | IOException e) {
+                log.error(sm.getString("contextConfig.noAntiLocking", 
context.getName()), e);
                 return;
             }
             antiLockingDocBase = antiLockingDocBase.getAbsoluteFile();
@@ -978,8 +978,6 @@ public class ContextConfig implements LifecycleListener {
                 log.debug(sm.getString("contextConfig.antiLocking", 
context.getName(), antiLockingDocBase.getPath()));
             }
 
-            // Cleanup just in case an old deployment is lying around
-            ExpandWar.delete(antiLockingDocBase);
             if (ExpandWar.copy(docBaseFile, antiLockingDocBase)) {
                 context.setDocBase(antiLockingDocBase.getPath());
             }
diff --git a/java/org/apache/catalina/startup/ExpandWar.java 
b/java/org/apache/catalina/startup/ExpandWar.java
index 589ec57843..85fc1ce2f3 100644
--- a/java/org/apache/catalina/startup/ExpandWar.java
+++ b/java/org/apache/catalina/startup/ExpandWar.java
@@ -236,7 +236,7 @@ public class ExpandWar {
         String[] files;
         if (src.isDirectory()) {
             files = src.list();
-            result = dest.mkdir();
+            result = dest.isDirectory() || dest.mkdir();
         } else {
             files = new String[1];
             files[0] = "";
diff --git a/webapps/docs/config/context.xml b/webapps/docs/config/context.xml
index 3d0e378310..604e8e8207 100644
--- a/webapps/docs/config/context.xml
+++ b/webapps/docs/config/context.xml
@@ -847,6 +847,12 @@
         be <strong>deleted</strong> on Tomcat shutdown.  You probably don't 
want
         to do this, so think twice before setting antiResourceLocking=true on a
         webapp that's outside the <code>appBase</code> for its Host.</p>
+
+        <p>If Tomcat terminates abnormally, the temporary copy of the web
+        application will not be deleted and must be cleaned-up manually. It 
will
+        be in the JVM default temporary directory. If Tomcat has been 
restarted,
+        take care to check the timestamps before deleting any web application
+        copies to make sure you are not deleting any currently in use.</p>
       </attribute>
 
       <attribute name="clearReferencesHttpClientKeepAliveThread" 
required="false">


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to