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 9f95350c7f Review Return null from ResourceLinkFactory when the global
naming..."
9f95350c7f is described below
commit 9f95350c7f946f76cad01c7b99797f1f2f8d34b4
Author: Mark Thomas <[email protected]>
AuthorDate: Fri Nov 6 18:46:19 2026 +0000
Review Return null from ResourceLinkFactory when the global naming..."
Fix double read of global context
---
java/org/apache/naming/factory/ResourceLinkFactory.java | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/java/org/apache/naming/factory/ResourceLinkFactory.java
b/java/org/apache/naming/factory/ResourceLinkFactory.java
index 9dbfebde55..8db280ab2f 100644
--- a/java/org/apache/naming/factory/ResourceLinkFactory.java
+++ b/java/org/apache/naming/factory/ResourceLinkFactory.java
@@ -176,11 +176,13 @@ public class ResourceLinkFactory implements ObjectFactory
{
// The global context may be missing if the web application was
// registered before the server created its naming context, which
// can happen with embedded start-up ordering
- if (globalContext == null) {
+ // Read the field once so that a concurrent change cannot lead to
a null being dereferenced
+ Context global = globalContext;
+ if (global == null) {
log.warn(sm.getString("resourceLinkFactory.noGlobalContext",
globalName));
return null;
}
- Object result = globalContext.lookup(globalName);
+ Object result = global.lookup(globalName);
if (result == null) {
return null;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]