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

remm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/master by this push:
     new 1e99eaf  Fix rename operation
1e99eaf is described below

commit 1e99eaf16aee080bcb8b8c363373d4f4d2676bbc
Author: remm <r...@apache.org>
AuthorDate: Fri Mar 5 10:20:54 2021 +0100

    Fix rename operation
    
    If the destination does not exist, Files.move throws an exception so it
    is not fully equivalent to the File.renameTo method that was used before
    which returns false in that case.
---
 java/org/apache/catalina/startup/HostConfig.java | 4 +++-
 webapps/docs/changelog.xml                       | 8 ++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/startup/HostConfig.java 
b/java/org/apache/catalina/startup/HostConfig.java
index b34ea58..864a742 100644
--- a/java/org/apache/catalina/startup/HostConfig.java
+++ b/java/org/apache/catalina/startup/HostConfig.java
@@ -1297,7 +1297,9 @@ public class HostConfig implements LifecycleListener {
             migration.execute();
 
             // Use rename
-            Files.move(destination.toPath(), tempOld.toPath());
+            if (destination.exists()) {
+                Files.move(destination.toPath(), tempOld.toPath());
+            }
             Files.move(tempNew.toPath(), destination.toPath());
             ExpandWar.delete(tempOld);
 
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index e547467..2317d9e 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -104,6 +104,14 @@
   issues do not "pop up" wrt. others).
 -->
 <section name="Tomcat 10.0.4 (markt)" rtext="in development">
+  <subsection name="Catalina">
+    <changelog>
+      <fix>
+        Fix rename operation throwing an exception during the webapp migration
+        process. (remm)
+      </fix>
+    </changelog>
+  </subsection>
 </section>
 <section name="Tomcat 10.0.3 (markt)" rtext="release in progress">
   <subsection name="Catalina">


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

Reply via email to