This is an automated email from the ASF dual-hosted git repository. markt-asf pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit a411beb2ccebc29c6080327633f1adb76024a64d 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]
