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

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

commit 5d1a89750db0be6c7551cd39d2567c3f64dd44b3
Author: opencode <[email protected]>
AuthorDate: Wed Sep 30 13:46:39 2026 +0200

    Only release the shared naming entry name in NamingResourcesImpl remove*() 
methods when the type-specific map actually held the entry, preventing the 
removal of the JNDI name reservation of a differently typed descriptor with the 
same name
---
 .../catalina/deploy/NamingResourcesImpl.java       | 40 +++++++++++++---------
 1 file changed, 24 insertions(+), 16 deletions(-)

diff --git a/java/org/apache/catalina/deploy/NamingResourcesImpl.java 
b/java/org/apache/catalina/deploy/NamingResourcesImpl.java
index f51f012c1d..1b9c84b10e 100644
--- a/java/org/apache/catalina/deploy/NamingResourcesImpl.java
+++ b/java/org/apache/catalina/deploy/NamingResourcesImpl.java
@@ -728,11 +728,12 @@ public class NamingResourcesImpl extends 
LifecycleMBeanBase implements Serializa
      */
     public void removeEjb(String name) {
 
-        entries.remove(name);
-
         ContextEjb ejb;
         synchronized (ejbs) {
             ejb = ejbs.remove(name);
+            if (ejb != null) {
+                entries.remove(name);
+            }
         }
         if (ejb != null) {
             support.firePropertyChange("ejb", ejb, null);
@@ -745,11 +746,12 @@ public class NamingResourcesImpl extends 
LifecycleMBeanBase implements Serializa
     @Override
     public void removeEnvironment(String name) {
 
-        entries.remove(name);
-
         ContextEnvironment environment;
         synchronized (envs) {
             environment = envs.remove(name);
+            if (environment != null) {
+                entries.remove(name);
+            }
         }
         if (environment != null) {
             support.firePropertyChange("environment", environment, null);
@@ -773,11 +775,12 @@ public class NamingResourcesImpl extends 
LifecycleMBeanBase implements Serializa
      */
     public void removeLocalEjb(String name) {
 
-        entries.remove(name);
-
         ContextLocalEjb localEjb;
         synchronized (localEjbs) {
             localEjb = localEjbs.remove(name);
+            if (localEjb != null) {
+                entries.remove(name);
+            }
         }
         if (localEjb != null) {
             support.firePropertyChange("localEjb", localEjb, null);
@@ -794,11 +797,12 @@ public class NamingResourcesImpl extends 
LifecycleMBeanBase implements Serializa
      */
     public void removeMessageDestinationRef(String name) {
 
-        entries.remove(name);
-
         MessageDestinationRef mdr;
         synchronized (mdrs) {
             mdr = mdrs.remove(name);
+            if (mdr != null) {
+                entries.remove(name);
+            }
         }
         if (mdr != null) {
             support.firePropertyChange("messageDestinationRef", mdr, null);
@@ -823,11 +827,12 @@ public class NamingResourcesImpl extends 
LifecycleMBeanBase implements Serializa
     @Override
     public void removeResource(String name) {
 
-        entries.remove(name);
-
         ContextResource resource;
         synchronized (resources) {
             resource = resources.remove(name);
+            if (resource != null) {
+                entries.remove(name);
+            }
         }
         if (resource != null) {
             support.firePropertyChange("resource", resource, null);
@@ -851,11 +856,12 @@ public class NamingResourcesImpl extends 
LifecycleMBeanBase implements Serializa
      */
     public void removeResourceEnvRef(String name) {
 
-        entries.remove(name);
-
         ContextResourceEnvRef resourceEnvRef;
         synchronized (resourceEnvRefs) {
             resourceEnvRef = resourceEnvRefs.remove(name);
+            if (resourceEnvRef != null) {
+                entries.remove(name);
+            }
         }
         if (resourceEnvRef != null) {
             support.firePropertyChange("resourceEnvRef", resourceEnvRef, null);
@@ -868,11 +874,12 @@ public class NamingResourcesImpl extends 
LifecycleMBeanBase implements Serializa
     @Override
     public void removeResourceLink(String name) {
 
-        entries.remove(name);
-
         ContextResourceLink resourceLink;
         synchronized (resourceLinks) {
             resourceLink = resourceLinks.remove(name);
+            if (resourceLink != null) {
+                entries.remove(name);
+            }
         }
         if (resourceLink != null) {
             support.firePropertyChange("resourceLink", resourceLink, null);
@@ -896,11 +903,12 @@ public class NamingResourcesImpl extends 
LifecycleMBeanBase implements Serializa
      */
     public void removeService(String name) {
 
-        entries.remove(name);
-
         ContextService service;
         synchronized (services) {
             service = services.remove(name);
+            if (service != null) {
+                entries.remove(name);
+            }
         }
         if (service != null) {
             support.firePropertyChange("service", service, null);


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

Reply via email to