Skip to content

Commit dcd25ab

Browse files
committed
Improve null-safety of module/spring-boot-security
See gh-46926
1 parent 99629d0 commit dcd25ab

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

module/spring-boot-security/src/main/java/org/springframework/boot/security/reactive/ApplicationContextServerWebExchangeMatcher.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,18 @@ protected boolean ignoreApplicationContext(@Nullable ApplicationContext applicat
8080
}
8181

8282
protected Supplier<C> getContext(ServerWebExchange exchange) {
83-
if (this.context == null) {
83+
Supplier<C> context = this.context;
84+
if (context == null) {
8485
synchronized (this.contextLock) {
85-
if (this.context == null) {
86-
Supplier<C> createdContext = createContext(exchange);
87-
initialized(createdContext);
88-
this.context = createdContext;
86+
context = this.context;
87+
if (context == null) {
88+
context = createContext(exchange);
89+
initialized(context);
90+
this.context = context;
8991
}
9092
}
9193
}
92-
return this.context;
94+
return context;
9395
}
9496

9597
/**

0 commit comments

Comments
 (0)