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

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

commit 152cd3b076fdd1978e446803b2e4175fdbd8b397
Author: opencode <[email protected]>
AuthorDate: Fri Oct 9 10:34:59 2026 +0200

    Log the ignored IOException when storing a child element fails
    
    storeElementArray() caught and silently discarded IOExceptions thrown
    per element. Those exceptions are only produced by the context
    separate-file storage paths (storeWithBackup / storeContextSeparate)
    when the target file cannot be written, and those methods throw without
    logging. A context whose configuration file could not be written was
    therefore dropped from a full configuration save without any log entry,
    while the save reported success, so the administrator's changes were
    silently lost on the next restart.
    
    Report a warning naming the element class along with the exception, and
    keep storing the remaining elements as before.
---
 java/org/apache/catalina/storeconfig/LocalStrings.properties | 1 +
 java/org/apache/catalina/storeconfig/StoreFactoryBase.java   | 7 ++++---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/catalina/storeconfig/LocalStrings.properties 
b/java/org/apache/catalina/storeconfig/LocalStrings.properties
index 2eb04ce46f..aabbe211ad 100644
--- a/java/org/apache/catalina/storeconfig/LocalStrings.properties
+++ b/java/org/apache/catalina/storeconfig/LocalStrings.properties
@@ -19,6 +19,7 @@ config.objectNameNotFound=Object name [{0}] not found
 config.storeContextError=Error storing context [{0}]
 config.storeServerError=Error storing server
 
+factory.storeElementFailed=Failed to store element [{0}], it will be missing 
from the stored configuration
 factory.storeNoDescriptor=Descriptor for element class [{0}] not configured!
 factory.storeTag=store tag [{0}] ( Object: [{1}] )
 
diff --git a/java/org/apache/catalina/storeconfig/StoreFactoryBase.java 
b/java/org/apache/catalina/storeconfig/StoreFactoryBase.java
index 5cbb2ede30..273b1f24a9 100644
--- a/java/org/apache/catalina/storeconfig/StoreFactoryBase.java
+++ b/java/org/apache/catalina/storeconfig/StoreFactoryBase.java
@@ -169,9 +169,10 @@ public class StoreFactoryBase implements IStoreFactory {
             for (Object element : elements) {
                 try {
                     storeElement(aWriter, indent, element);
-                } catch (IOException ignore) {
-                    // Ignore. Children do not report the error themselves 
(e.g.
-                    // StandardContextSF.storeWithBackup() throws without 
logging).
+                } catch (IOException ioe) {
+                    // Keep storing the other elements but report the failure 
since some children throw without
+                    // logging the error themselves (e.g. 
StandardContextSF.storeWithBackup())
+                    log.warn(sm.getString("factory.storeElementFailed", 
element.getClass().getName()), ioe);
                 }
             }
         }


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

Reply via email to