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 bde0fbc97ccfdafb91ea5681caaf5489c4ca25ed Author: opencode <[email protected]> AuthorDate: Wed Sep 30 13:42:17 2026 +0200 Retain an existing resource link in NamingResourcesImpl.addEnvironment() when the link's global target is not an overridable global environment rather than adding an environment entry with the same name which would create a duplicate JNDI binding --- .../catalina/deploy/NamingResourcesImpl.java | 23 +++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/java/org/apache/catalina/deploy/NamingResourcesImpl.java b/java/org/apache/catalina/deploy/NamingResourcesImpl.java index f0631bfd8d..5d035343bf 100644 --- a/java/org/apache/catalina/deploy/NamingResourcesImpl.java +++ b/java/org/apache/catalina/deploy/NamingResourcesImpl.java @@ -269,13 +269,22 @@ public class NamingResourcesImpl extends LifecycleMBeanBase implements Serializa } } else if (rl != null) { // Link. Need to look at the global resources - NamingResourcesImpl global = getServer().getGlobalNamingResources(); - if (global.findEnvironment(rl.getGlobal()) != null) { - if (global.findEnvironment(rl.getGlobal()).getOverride()) { - removeResourceLink(environment.getName()); - } else { - return; - } + Server server = getServer(); + if (server == null) { + return; + } + NamingResourcesImpl global = server.getGlobalNamingResources(); + ContextEnvironment globalEnv = global.findEnvironment(rl.getGlobal()); + if (globalEnv != null && globalEnv.getOverride()) { + removeResourceLink(environment.getName()); + } else { + // The link targets a global entry that may not be + // overridden, or something that is not a global + // environment at all (or is missing). In those cases the + // existing link is retained. Adding the environment entry + // as well would result in two entries sharing one JNDI + // name. + return; } } else { // It exists but it isn't an env or a res link... --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
