Polish contribution

- Update copyright headers
 - Use kebab-case for the property name
 - Set the header unconditionally when the filter's registered

Closes gh-4320
This commit is contained in:
Andy Wilkinson 2016-01-15 17:44:04 +00:00
parent c219f5e57f
commit f5b973a242
2 changed files with 4 additions and 13 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -200,7 +200,7 @@ public class EndpointWebMvcAutoConfiguration
// Put Servlets and Filters in their own nested class so they don't force early // Put Servlets and Filters in their own nested class so they don't force early
// instantiation of ManagementServerProperties. // instantiation of ManagementServerProperties.
@Configuration @Configuration
@ConditionalOnProperty(prefix = "management", name = "addApplicationContextHeader", matchIfMissing = true, havingValue = "true") @ConditionalOnProperty(prefix = "management", name = "add-application-context-header", matchIfMissing = true, havingValue = "true")
protected static class ApplicationContextFilterConfiguration { protected static class ApplicationContextFilterConfiguration {
@Bean @Bean
@ -225,8 +225,6 @@ public class EndpointWebMvcAutoConfiguration
private final ApplicationContext applicationContext; private final ApplicationContext applicationContext;
private ManagementServerProperties properties;
ApplicationContextHeaderFilter(ApplicationContext applicationContext) { ApplicationContextHeaderFilter(ApplicationContext applicationContext) {
this.applicationContext = applicationContext; this.applicationContext = applicationContext;
} }
@ -235,14 +233,7 @@ public class EndpointWebMvcAutoConfiguration
protected void doFilterInternal(HttpServletRequest request, protected void doFilterInternal(HttpServletRequest request,
HttpServletResponse response, FilterChain filterChain) HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException { throws ServletException, IOException {
if (this.properties == null) { response.addHeader("X-Application-Context", this.applicationContext.getId());
this.properties = this.applicationContext
.getBean(ManagementServerProperties.class);
}
if (this.properties.getAddApplicationContextHeader()) {
response.addHeader("X-Application-Context",
this.applicationContext.getId());
}
filterChain.doFilter(request, response); filterChain.doFilter(request, response);
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2015 the original author or authors. * Copyright 2012-2016 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.