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

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


The following commit(s) were added to refs/heads/11.0.x by this push:
     new a10d6b4f06 DCL needs volatile variables. Don't cache null result.
a10d6b4f06 is described below

commit a10d6b4f067a7d417531879d1a6991f5fc3734fd
Author: Mark Thomas <[email protected]>
AuthorDate: Fri Jun 19 14:04:38 2026 +0100

    DCL needs volatile variables. Don't cache null result.
---
 java/org/apache/naming/NamingContext.java | 7 +++++--
 java/org/apache/naming/NamingEntry.java   | 4 ++--
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/naming/NamingContext.java 
b/java/org/apache/naming/NamingContext.java
index 5da0f2d522..212dd0831f 100644
--- a/java/org/apache/naming/NamingContext.java
+++ b/java/org/apache/naming/NamingContext.java
@@ -527,8 +527,11 @@ public class NamingContext implements Context {
                                         (String) ((ResourceRef) 
entry.value).get(ResourceRef.SINGLETON).getContent());
                                 if (singleton) {
                                     obj = getObjectInstance(name, entry);
-                                    entry.type = NamingEntry.ENTRY;
-                                    entry.value = obj;
+                                    // If reference resolution fails, don't 
cache failed result.
+                                    if (obj != null) {
+                                        entry.value = obj;
+                                        entry.type = NamingEntry.ENTRY;
+                                    }
                                 }
                             } else {
                                 // Another thread has created the singleton
diff --git a/java/org/apache/naming/NamingEntry.java 
b/java/org/apache/naming/NamingEntry.java
index e1b0ddbc30..1865566c78 100644
--- a/java/org/apache/naming/NamingEntry.java
+++ b/java/org/apache/naming/NamingEntry.java
@@ -60,7 +60,7 @@ public class NamingEntry {
     /**
      * The type instance variable is used to avoid using RTTI when doing 
lookups.
      */
-    public int type;
+    public volatile int type;
 
     /**
      * The binding name.
@@ -70,7 +70,7 @@ public class NamingEntry {
     /**
      * The bound object value.
      */
-    public Object value;
+    public volatile Object value;
 
 
     @Override


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

Reply via email to