Skip to content

Commit 4212ee7

Browse files
committed
Merge branch '3.4.x'
Closes gh-44190
2 parents 4ab96f1 + 3603cb4 commit 4212ee7

File tree

2 files changed

+15
-6
lines changed
  • spring-boot-project/spring-boot-actuator-autoconfigure/src

2 files changed

+15
-6
lines changed

Diff for: spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/security/servlet/EndpointRequest.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,14 @@ protected boolean ignoreApplicationContext(WebApplicationContext applicationCont
185185
protected final boolean hasWebServerNamespace(ApplicationContext applicationContext,
186186
WebServerNamespace webServerNamespace) {
187187
return WebServerApplicationContext.hasServerNamespace(applicationContext, webServerNamespace.getValue())
188-
|| (webServerNamespace.equals(WebServerNamespace.SERVER)
189-
&& !(applicationContext instanceof WebServerApplicationContext));
188+
|| hasImplicitServerNamespace(applicationContext, webServerNamespace);
189+
}
190+
191+
private boolean hasImplicitServerNamespace(ApplicationContext applicationContext,
192+
WebServerNamespace webServerNamespace) {
193+
return WebServerNamespace.SERVER.equals(webServerNamespace)
194+
&& WebServerApplicationContext.getServerNamespace(applicationContext) == null
195+
&& applicationContext.getParent() == null;
190196
}
191197

192198
@Override

Diff for: spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/EndpointRequestTests.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -349,9 +349,12 @@ private RequestMatcherAssert assertMatcher(RequestMatcher matcher, PathMappedEnd
349349
}
350350

351351
private RequestMatcherAssert assertMatcher(RequestMatcher matcher, PathMappedEndpoints pathMappedEndpoints,
352-
RequestMatcherProvider matcherProvider, WebServerNamespace webServerNamespace) {
353-
StaticWebApplicationContext context = (webServerNamespace != null)
354-
? new NamedStaticWebApplicationContext(webServerNamespace) : new StaticWebApplicationContext();
352+
RequestMatcherProvider matcherProvider, WebServerNamespace namespace) {
353+
StaticWebApplicationContext context = new StaticWebApplicationContext();
354+
if (namespace != null && !WebServerNamespace.SERVER.equals(namespace)) {
355+
NamedStaticWebApplicationContext parentContext = new NamedStaticWebApplicationContext(namespace);
356+
context.setParent(parentContext);
357+
}
355358
context.registerBean(WebEndpointProperties.class);
356359
if (pathMappedEndpoints != null) {
357360
context.registerBean(PathMappedEndpoints.class, () -> pathMappedEndpoints);
@@ -382,7 +385,7 @@ public WebServer getWebServer() {
382385

383386
@Override
384387
public String getServerNamespace() {
385-
return this.webServerNamespace.getValue();
388+
return (this.webServerNamespace != null) ? this.webServerNamespace.getValue() : null;
386389
}
387390

388391
}

0 commit comments

Comments
 (0)