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 0525d59f9d7924eaa5c2b0032a2d52dec3f40d2d
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 6e0612871a..f330f0ae0f 100644
--- a/java/org/apache/catalina/deploy/NamingResourcesImpl.java
+++ b/java/org/apache/catalina/deploy/NamingResourcesImpl.java
@@ -730,11 +730,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);
@@ -747,11 +748,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);
@@ -775,11 +777,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);
@@ -796,11 +799,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);
@@ -825,11 +829,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);
@@ -853,11 +858,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);
@@ -870,11 +876,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);
@@ -898,11 +905,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