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 2cca94753b Review Return null from ResourceLinkFactory when the global
naming..."
2cca94753b is described below
commit 2cca94753bdb220fbf526f875c78df906177290b
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 4a959fcc27..2925b0b35d 100644
--- a/java/org/apache/naming/factory/ResourceLinkFactory.java
+++ b/java/org/apache/naming/factory/ResourceLinkFactory.java
@@ -181,11 +181,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]