mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Cache management port type in EndpointRequestMatcher
Closes gh-20329
This commit is contained in:
parent
421fe77b04
commit
cdae79dad9
@ -130,6 +130,8 @@ public final class EndpointRequest {
|
||||
|
||||
private volatile ServerWebExchangeMatcher delegate;
|
||||
|
||||
private static ManagementPortType managementPortType;
|
||||
|
||||
private EndpointServerWebExchangeMatcher(boolean includeLinks) {
|
||||
this(Collections.emptyList(), Collections.emptyList(), includeLinks);
|
||||
}
|
||||
@ -231,7 +233,10 @@ public final class EndpointRequest {
|
||||
|
||||
static boolean isManagementContext(ServerWebExchange exchange) {
|
||||
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) {
|
||||
return false;
|
||||
}
|
||||
|
@ -124,14 +124,18 @@ public final class EndpointRequest {
|
||||
|
||||
private volatile RequestMatcher delegate;
|
||||
|
||||
private static ManagementPortType managementPortType;
|
||||
|
||||
AbstractRequestMatcher() {
|
||||
super(WebApplicationContext.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean ignoreApplicationContext(WebApplicationContext applicationContext) {
|
||||
ManagementPortType type = ManagementPortType.get(applicationContext.getEnvironment());
|
||||
return type == ManagementPortType.DIFFERENT
|
||||
if (managementPortType == null) {
|
||||
managementPortType = ManagementPortType.get(applicationContext.getEnvironment());
|
||||
}
|
||||
return managementPortType == ManagementPortType.DIFFERENT
|
||||
&& !WebServerApplicationContext.hasServerNamespace(applicationContext, "management");
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user