Skip to content

Commit 6de479f

Browse files
committed
Polish
1 parent 93046d0 commit 6de479f

File tree

4 files changed

+35
-21
lines changed

4 files changed

+35
-21
lines changed

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

+24-13
Original file line numberDiff line numberDiff line change
@@ -165,35 +165,40 @@ public EndpointRequestMatcher excludingLinks() {
165165
}
166166

167167
@Override
168-
protected void initialized(Supplier<WebApplicationContext> webApplicationContext) {
168+
protected void initialized(
169+
Supplier<WebApplicationContext> webApplicationContext) {
169170
this.delegate = createDelegate(webApplicationContext);
170171
}
171172

172173
private RequestMatcher createDelegate(
173174
Supplier<WebApplicationContext> webApplicationContext) {
174175
try {
175176
WebApplicationContext context = webApplicationContext.get();
176-
PathMappedEndpoints pathMappedEndpoints = context.getBean(PathMappedEndpoints.class);
177-
DispatcherServletPathProvider pathProvider = context.getBean(DispatcherServletPathProvider.class);
177+
PathMappedEndpoints pathMappedEndpoints = context
178+
.getBean(PathMappedEndpoints.class);
179+
DispatcherServletPathProvider pathProvider = context
180+
.getBean(DispatcherServletPathProvider.class);
178181
return createDelegate(pathMappedEndpoints, pathProvider.getServletPath());
179182
}
180183
catch (NoSuchBeanDefinitionException ex) {
181184
return EMPTY_MATCHER;
182185
}
183186
}
184187

185-
private RequestMatcher createDelegate(PathMappedEndpoints pathMappedEndpoints, String servletPath) {
188+
private RequestMatcher createDelegate(PathMappedEndpoints pathMappedEndpoints,
189+
String servletPath) {
186190
Set<String> paths = new LinkedHashSet<>();
187191
if (this.includes.isEmpty()) {
188192
paths.addAll(pathMappedEndpoints.getAllPaths());
189193
}
190194
streamPaths(this.includes, pathMappedEndpoints).forEach(paths::add);
191195
streamPaths(this.excludes, pathMappedEndpoints).forEach(paths::remove);
192-
List<RequestMatcher> delegateMatchers = getDelegateMatchers(servletPath, paths);
196+
List<RequestMatcher> delegateMatchers = getDelegateMatchers(servletPath,
197+
paths);
193198
if (this.includeLinks
194199
&& StringUtils.hasText(pathMappedEndpoints.getBasePath())) {
195-
delegateMatchers.add(
196-
new AntPathRequestMatcher(servletPath + pathMappedEndpoints.getBasePath()));
200+
delegateMatchers.add(new AntPathRequestMatcher(
201+
servletPath + pathMappedEndpoints.getBasePath()));
197202
}
198203
return new OrRequestMatcher(delegateMatchers);
199204
}
@@ -221,8 +226,10 @@ private String getEndpointId(Class<?> source) {
221226
return annotation.id();
222227
}
223228

224-
private List<RequestMatcher> getDelegateMatchers(String servletPath, Set<String> paths) {
225-
return paths.stream().map((path) -> new AntPathRequestMatcher(servletPath + path + "/**"))
229+
private List<RequestMatcher> getDelegateMatchers(String servletPath,
230+
Set<String> paths) {
231+
return paths.stream()
232+
.map((path) -> new AntPathRequestMatcher(servletPath + path + "/**"))
226233
.collect(Collectors.toList());
227234
}
228235

@@ -247,19 +254,23 @@ private LinksRequestMatcher() {
247254
}
248255

249256
@Override
250-
protected void initialized(Supplier<WebApplicationContext> webApplicationContext) {
257+
protected void initialized(
258+
Supplier<WebApplicationContext> webApplicationContext) {
251259
try {
252260
WebApplicationContext context = webApplicationContext.get();
253-
WebEndpointProperties properties = context.getBean(WebEndpointProperties.class);
254-
DispatcherServletPathProvider pathProvider = context.getBean(DispatcherServletPathProvider.class);
261+
WebEndpointProperties properties = context
262+
.getBean(WebEndpointProperties.class);
263+
DispatcherServletPathProvider pathProvider = context
264+
.getBean(DispatcherServletPathProvider.class);
255265
this.delegate = createDelegate(pathProvider.getServletPath(), properties);
256266
}
257267
catch (NoSuchBeanDefinitionException ex) {
258268
this.delegate = EMPTY_MATCHER;
259269
}
260270
}
261271

262-
private RequestMatcher createDelegate(String path, WebEndpointProperties properties) {
272+
private RequestMatcher createDelegate(String path,
273+
WebEndpointProperties properties) {
263274
if (StringUtils.hasText(properties.getBasePath())) {
264275
return new AntPathRequestMatcher(path + properties.getBasePath());
265276
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/servlet/WebMvcEndpointChildContextConfigurationTests.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ public void contextShouldNotConfigureRequestContextFilterWhenRequestContextListe
6565

6666
@Test
6767
public void contextShouldConfigureDispatcherServletPathProviderWithEmptyPath() {
68-
this.contextRunner.withUserConfiguration(WebMvcEndpointChildContextConfiguration.class)
69-
.run((context) -> assertThat(context.getBean(DispatcherServletPathProvider.class)
70-
.getServletPath()).isEmpty());
68+
this.contextRunner
69+
.withUserConfiguration(WebMvcEndpointChildContextConfiguration.class)
70+
.run((context) -> assertThat(context
71+
.getBean(DispatcherServletPathProvider.class).getServletPath())
72+
.isEmpty());
7173
}
7274

7375
static class ExistingConfig {

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,8 @@ protected static class DispatcherServletConfiguration {
9090

9191
private final ServerProperties serverProperties;
9292

93-
public DispatcherServletConfiguration(WebMvcProperties webMvcProperties, ServerProperties serverProperties) {
93+
public DispatcherServletConfiguration(WebMvcProperties webMvcProperties,
94+
ServerProperties serverProperties) {
9495
this.webMvcProperties = webMvcProperties;
9596
this.serverProperties = serverProperties;
9697
}
@@ -117,7 +118,8 @@ public MultipartResolver multipartResolver(MultipartResolver resolver) {
117118

118119
@Bean
119120
public DispatcherServletPathProvider mainDispatcherServletPathProvider() {
120-
return () -> DispatcherServletConfiguration.this.serverProperties.getServlet().getPath();
121+
return () -> DispatcherServletConfiguration.this.serverProperties.getServlet()
122+
.getPath();
121123
}
122124

123125
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/DispatcherServletPathProvider.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
import org.springframework.web.servlet.DispatcherServlet;
2020

2121
/**
22-
* Interface that provides the path of the {@link DispatcherServlet} in
23-
* an application context.
22+
* Interface that provides the path of the {@link DispatcherServlet} in an application
23+
* context.
2424
*
2525
* @author Madhura Bhave
2626
* @since 2.0.2
@@ -31,4 +31,3 @@ public interface DispatcherServletPathProvider {
3131
String getServletPath();
3232

3333
}
34-

0 commit comments

Comments
 (0)