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

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


The following commit(s) were added to refs/heads/9.0.x by this push:
     new a0e377e34f Avoid backup overwrite if they occur more than once every 
second
a0e377e34f is described below

commit a0e377e34fd95a5d1d526131b6a419ed62408baf
Author: remm <r...@apache.org>
AuthorDate: Tue Sep 24 09:50:07 2024 +0200

    Avoid backup overwrite if they occur more than once every second
    
    This would lose the original file.
---
 java/org/apache/catalina/storeconfig/StoreFileMover.java | 12 ++++++++----
 webapps/docs/changelog.xml                               |  4 ++++
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/catalina/storeconfig/StoreFileMover.java 
b/java/org/apache/catalina/storeconfig/StoreFileMover.java
index 9e245f5fc0..1e5e5dc775 100644
--- a/java/org/apache/catalina/storeconfig/StoreFileMover.java
+++ b/java/org/apache/catalina/storeconfig/StoreFileMover.java
@@ -150,10 +150,14 @@ public class StoreFileMover {
             }
         }
         String sb = getTimeTag();
-        configSave = new File(configFile + sb);
-        if (!configSave.isAbsolute()) {
-            configSave = new File(getBasename(), configFile + sb);
-        }
+        int i = 0;
+        do {
+            configSave = new File(configFile + sb + "-" + String.valueOf(i));
+            if (!configSave.isAbsolute()) {
+                configSave = new File(getBasename(), configFile + sb + "-" + 
String.valueOf(i));
+            }
+            i++;
+        } while (configSave.exists());
     }
 
     /**
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 008f64ce7c..bbc8ca1e61 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -133,6 +133,10 @@
         <code>null</code> if the <code>CallerPrincipalCallback</code> does not
         provide a Principal. (markt)
       </fix>
+      <fix>
+        Avoid store config backup loss when storing one configuration more than
+        once per second. (remm)
+      </fix>
     </changelog>
   </subsection>
   <subsection name="Coyote">


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

Reply via email to