Commit cdae79da authored by Madhura Bhave's avatar Madhura Bhave

Cache management port type in EndpointRequestMatcher

Closes gh-20329
parent 421fe77b
...@@ -130,6 +130,8 @@ public final class EndpointRequest { ...@@ -130,6 +130,8 @@ public final class EndpointRequest {
private volatile ServerWebExchangeMatcher delegate; private volatile ServerWebExchangeMatcher delegate;
private static ManagementPortType managementPortType;
private EndpointServerWebExchangeMatcher(boolean includeLinks) { private EndpointServerWebExchangeMatcher(boolean includeLinks) {
this(Collections.emptyList(), Collections.emptyList(), includeLinks); this(Collections.emptyList(), Collections.emptyList(), includeLinks);
} }
...@@ -231,7 +233,10 @@ public final class EndpointRequest { ...@@ -231,7 +233,10 @@ public final class EndpointRequest {
static boolean isManagementContext(ServerWebExchange exchange) { static boolean isManagementContext(ServerWebExchange exchange) {
ApplicationContext applicationContext = exchange.getApplicationContext(); ApplicationContext applicationContext = exchange.getApplicationContext();
if (ManagementPortType.get(applicationContext.getEnvironment()) == ManagementPortType.DIFFERENT) { if (managementPortType == null) {
managementPortType = ManagementPortType.get(applicationContext.getEnvironment());
}
if (managementPortType == ManagementPortType.DIFFERENT) {
if (applicationContext.getParent() == null) { if (applicationContext.getParent() == null) {
return false; return false;
} }
......
...@@ -124,14 +124,18 @@ public final class EndpointRequest { ...@@ -124,14 +124,18 @@ public final class EndpointRequest {
private volatile RequestMatcher delegate; private volatile RequestMatcher delegate;
private static ManagementPortType managementPortType;
AbstractRequestMatcher() { AbstractRequestMatcher() {
super(WebApplicationContext.class); super(WebApplicationContext.class);
} }
@Override @Override
protected boolean ignoreApplicationContext(WebApplicationContext applicationContext) { protected boolean ignoreApplicationContext(WebApplicationContext applicationContext) {
ManagementPortType type = ManagementPortType.get(applicationContext.getEnvironment()); if (managementPortType == null) {
return type == ManagementPortType.DIFFERENT managementPortType = ManagementPortType.get(applicationContext.getEnvironment());
}
return managementPortType == ManagementPortType.DIFFERENT
&& !WebServerApplicationContext.hasServerNamespace(applicationContext, "management"); && !WebServerApplicationContext.hasServerNamespace(applicationContext, "management");
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment