From 9c82d5c382f5654c9dab60cab5423650615b6543 Mon Sep 17 00:00:00 2001 From: Madhura Bhave Date: Tue, 4 Sep 2018 17:06:24 -0700 Subject: [PATCH] Make ApplicationContextServerWebExchangeMatcher and subclasses thread-safe Fixes gh-14161 --- .../autoconfigure/security/reactive/EndpointRequest.java | 4 ++-- .../reactive/ApplicationContextServerWebExchangeMatcher.java | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequest.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequest.java index 000032a209..942e979d72 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequest.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequest.java @@ -125,7 +125,7 @@ public final class EndpointRequest { private final boolean includeLinks; - private ServerWebExchangeMatcher delegate; + private volatile ServerWebExchangeMatcher delegate; private EndpointServerWebExchangeMatcher(boolean includeLinks) { this(Collections.emptyList(), Collections.emptyList(), includeLinks); @@ -246,7 +246,7 @@ public final class EndpointRequest { public static final class LinksServerWebExchangeMatcher extends ApplicationContextServerWebExchangeMatcher { - private ServerWebExchangeMatcher delegate; + private volatile ServerWebExchangeMatcher delegate; private LinksServerWebExchangeMatcher() { super(WebEndpointProperties.class); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/security/reactive/ApplicationContextServerWebExchangeMatcher.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/security/reactive/ApplicationContextServerWebExchangeMatcher.java index cdf0854aeb..390efe67bd 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/security/reactive/ApplicationContextServerWebExchangeMatcher.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/security/reactive/ApplicationContextServerWebExchangeMatcher.java @@ -70,8 +70,9 @@ public abstract class ApplicationContextServerWebExchangeMatcher if (this.context == null) { synchronized (this.contextLock) { if (this.context == null) { - this.context = createContext(exchange); - initialized(this.context); + Supplier createdContext = createContext(exchange); + initialized(createdContext); + this.context = createdContext; } } }