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

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

commit e8bb9125a3547fb142e680c7730da71094b20b9f
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
---
 .../org/apache/catalina/deploy/NamingResourcesImpl.java | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/java/org/apache/catalina/deploy/NamingResourcesImpl.java 
b/java/org/apache/catalina/deploy/NamingResourcesImpl.java
index e97f1706e9..bed94cff45 100644
--- a/java/org/apache/catalina/deploy/NamingResourcesImpl.java
+++ b/java/org/apache/catalina/deploy/NamingResourcesImpl.java
@@ -276,12 +276,17 @@ public class NamingResourcesImpl extends 
LifecycleMBeanBase implements Serializa
                     return;
                 }
                 NamingResourcesImpl global = server.getGlobalNamingResources();
-                if (global.findEnvironment(rl.getGlobal()) != null) {
-                    if (global.findEnvironment(rl.getGlobal()).getOverride()) {
-                        removeResourceLink(environment.getName());
-                    } else {
-                        return;
-                    }
+                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]

Reply via email to