You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2026/10/09 10:44:12 UTC
(tomcat) 05/15: Log the ignored IOException when storing a child element fails
This is an automated email from the ASF dual-hosted git repository.
rmaucher pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 47ebd7c9414a9c1c0af7e6fba426ce414c2bdc74
Author: opencode <re...@apache.org>
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 e26bf11e07..33f5ee22fa 100644
--- a/java/org/apache/catalina/storeconfig/LocalStrings.properties
+++ b/java/org/apache/catalina/storeconfig/LocalStrings.properties
@@ -22,6 +22,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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org