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 55e07fdf7e568cf1ed0a5f7cd5ef281a93d0cdd4 Author: opencode <[email protected]> AuthorDate: Thu Oct 8 15:48:47 2026 +0200 Skip parsing a context configuration file that cannot be opened In processContextConfig() the InputSource was created before the input stream for the configuration file was opened, so the null check that guarded the parse was unreachable. When opening the file failed, for example an external context configuration file that does not exist, processing continued into digester.parse() with a byte-stream less InputSource, the SAX parser re-resolved the same URL and failed again, logging a second, duplicate error for the one problem. The stream is now opened before the InputSource is created. If opening fails, the single error is logged, the context is marked as not configured and parsing is skipped. The visible outcome for the deployment is unchanged; only the duplicate error output is removed. --- java/org/apache/catalina/startup/ContextConfig.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/java/org/apache/catalina/startup/ContextConfig.java b/java/org/apache/catalina/startup/ContextConfig.java index be46dfb836..21db7ad4a7 100644 --- a/java/org/apache/catalina/startup/ContextConfig.java +++ b/java/org/apache/catalina/startup/ContextConfig.java @@ -779,22 +779,21 @@ public class ContextConfig implements LifecycleListener { log.debug(sm.getString("contextConfig.processContext", context.getName(), contextXml)); } - InputSource source = null; + InputSource source; - try { - source = new InputSource(contextXml.toString()); - if (stream == null) { + if (stream == null) { + try { URLConnection xmlConn = contextXml.openConnection(); xmlConn.setUseCaches(false); stream = xmlConn.getInputStream(); + } catch (Exception e) { + log.error(sm.getString("contextConfig.contextMissing", contextXml), e); + ok = false; + return; } - } catch (Exception e) { - log.error(sm.getString("contextConfig.contextMissing", contextXml), e); } - if (source == null) { - return; - } + source = new InputSource(contextXml.toString()); try { source.setByteStream(stream); --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
