This is an automated email from the ASF dual-hosted git repository.
markt-asf pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new a76e40df10 DCL needs volatile variables. Don't cache null result.
a76e40df10 is described below
commit a76e40df10694f71c50ba3991ad7270766d562ba
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]