From dcd25abcce12dc11c406ff6b58d995a83b76dc66 Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Fri, 22 Aug 2025 11:09:52 +0200 Subject: [PATCH] Improve null-safety of module/spring-boot-security See gh-46926 --- ...ApplicationContextServerWebExchangeMatcher.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/module/spring-boot-security/src/main/java/org/springframework/boot/security/reactive/ApplicationContextServerWebExchangeMatcher.java b/module/spring-boot-security/src/main/java/org/springframework/boot/security/reactive/ApplicationContextServerWebExchangeMatcher.java index 18afd24ac93..393641e51c1 100644 --- a/module/spring-boot-security/src/main/java/org/springframework/boot/security/reactive/ApplicationContextServerWebExchangeMatcher.java +++ b/module/spring-boot-security/src/main/java/org/springframework/boot/security/reactive/ApplicationContextServerWebExchangeMatcher.java @@ -80,16 +80,18 @@ public abstract class ApplicationContextServerWebExchangeMatcher implements S } protected Supplier getContext(ServerWebExchange exchange) { - if (this.context == null) { + Supplier context = this.context; + if (context == null) { synchronized (this.contextLock) { - if (this.context == null) { - Supplier createdContext = createContext(exchange); - initialized(createdContext); - this.context = createdContext; + context = this.context; + if (context == null) { + context = createContext(exchange); + initialized(context); + this.context = context; } } } - return this.context; + return context; } /**