Skip to content

Commit f5b973a

Browse files
committed
Polish contribution
- Update copyright headers - Use kebab-case for the property name - Set the header unconditionally when the filter's registered Closes gh-4320
1 parent c219f5e commit f5b973a

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.java

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2015 the original author or authors.
2+
* Copyright 2012-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -200,7 +200,7 @@ public Object getProperty(String name) {
200200
// Put Servlets and Filters in their own nested class so they don't force early
201201
// instantiation of ManagementServerProperties.
202202
@Configuration
203-
@ConditionalOnProperty(prefix = "management", name = "addApplicationContextHeader", matchIfMissing = true, havingValue = "true")
203+
@ConditionalOnProperty(prefix = "management", name = "add-application-context-header", matchIfMissing = true, havingValue = "true")
204204
protected static class ApplicationContextFilterConfiguration {
205205

206206
@Bean
@@ -225,8 +225,6 @@ private static class ApplicationContextHeaderFilter extends OncePerRequestFilter
225225

226226
private final ApplicationContext applicationContext;
227227

228-
private ManagementServerProperties properties;
229-
230228
ApplicationContextHeaderFilter(ApplicationContext applicationContext) {
231229
this.applicationContext = applicationContext;
232230
}
@@ -235,14 +233,7 @@ private static class ApplicationContextHeaderFilter extends OncePerRequestFilter
235233
protected void doFilterInternal(HttpServletRequest request,
236234
HttpServletResponse response, FilterChain filterChain)
237235
throws ServletException, IOException {
238-
if (this.properties == null) {
239-
this.properties = this.applicationContext
240-
.getBean(ManagementServerProperties.class);
241-
}
242-
if (this.properties.getAddApplicationContextHeader()) {
243-
response.addHeader("X-Application-Context",
244-
this.applicationContext.getId());
245-
}
236+
response.addHeader("X-Application-Context", this.applicationContext.getId());
246237
filterChain.doFilter(request, response);
247238
}
248239

spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfigurationTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2015 the original author or authors.
2+
* Copyright 2012-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)