Make ApplicationContextServerWebExchangeMatcher and subclasses thread-safe

Fixes gh-14161
This commit is contained in:
Madhura Bhave
2018-09-04 17:06:24 -07:00
parent cafff43022
commit 9c82d5c382
2 changed files with 5 additions and 4 deletions

View File

@@ -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<WebEndpointProperties> {
private ServerWebExchangeMatcher delegate;
private volatile ServerWebExchangeMatcher delegate;
private LinksServerWebExchangeMatcher() {
super(WebEndpointProperties.class);

View File

@@ -70,8 +70,9 @@ public abstract class ApplicationContextServerWebExchangeMatcher<C>
if (this.context == null) {
synchronized (this.contextLock) {
if (this.context == null) {
this.context = createContext(exchange);
initialized(this.context);
Supplier<C> createdContext = createContext(exchange);
initialized(createdContext);
this.context = createdContext;
}
}
}