Commit e7a3b3c4 authored by Andy Wilkinson's avatar Andy Wilkinson

Polish

parent cf2bf0c2
...@@ -44,8 +44,7 @@ class ServletWebManagementContextFactory implements ManagementContextFactory { ...@@ -44,8 +44,7 @@ class ServletWebManagementContextFactory implements ManagementContextFactory {
ApplicationContext parent, Class<?>... configClasses) { ApplicationContext parent, Class<?>... configClasses) {
AnnotationConfigServletWebServerApplicationContext child = new AnnotationConfigServletWebServerApplicationContext(); AnnotationConfigServletWebServerApplicationContext child = new AnnotationConfigServletWebServerApplicationContext();
child.setParent(parent); child.setParent(parent);
List<Class<?>> combinedClasses = new ArrayList<Class<?>>( List<Class<?>> combinedClasses = new ArrayList<>(Arrays.asList(configClasses));
Arrays.asList(configClasses));
combinedClasses.add(ServletWebServerFactoryAutoConfiguration.class); combinedClasses.add(ServletWebServerFactoryAutoConfiguration.class);
child.register(combinedClasses.toArray(new Class<?>[combinedClasses.size()])); child.register(combinedClasses.toArray(new Class<?>[combinedClasses.size()]));
registerServletWebServerFactory(parent, child); registerServletWebServerFactory(parent, child);
......
...@@ -22,13 +22,12 @@ import org.springframework.boot.endpoint.CachingConfiguration; ...@@ -22,13 +22,12 @@ import org.springframework.boot.endpoint.CachingConfiguration;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
/** /**
* A {@link CachingConfiguration} factory that use the {@link Environment} to extract * A {@link CachingConfiguration} factory that use the {@link Environment} to extract the
* the caching settings of each endpoint. * caching settings of each endpoint.
* *
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
class CachingConfigurationFactory class CachingConfigurationFactory implements Function<String, CachingConfiguration> {
implements Function<String, CachingConfiguration> {
private final Environment environment; private final Environment environment;
......
...@@ -53,8 +53,7 @@ class JmxEndpointExporter implements InitializingBean, DisposableBean { ...@@ -53,8 +53,7 @@ class JmxEndpointExporter implements InitializingBean, DisposableBean {
private Collection<ObjectName> registeredObjectNames; private Collection<ObjectName> registeredObjectNames;
JmxEndpointExporter(EndpointProvider<JmxEndpointOperation> endpointProvider, JmxEndpointExporter(EndpointProvider<JmxEndpointOperation> endpointProvider,
EndpointMBeanRegistrar endpointMBeanRegistrar, EndpointMBeanRegistrar endpointMBeanRegistrar, ObjectMapper objectMapper) {
ObjectMapper objectMapper) {
this.endpointProvider = endpointProvider; this.endpointProvider = endpointProvider;
this.endpointMBeanRegistrar = endpointMBeanRegistrar; this.endpointMBeanRegistrar = endpointMBeanRegistrar;
DataConverter dataConverter = new DataConverter(objectMapper); DataConverter dataConverter = new DataConverter(objectMapper);
...@@ -73,8 +72,8 @@ class JmxEndpointExporter implements InitializingBean, DisposableBean { ...@@ -73,8 +72,8 @@ class JmxEndpointExporter implements InitializingBean, DisposableBean {
private Collection<ObjectName> registerEndpointMBeans() { private Collection<ObjectName> registerEndpointMBeans() {
List<ObjectName> objectNames = new ArrayList<>(); List<ObjectName> objectNames = new ArrayList<>();
Collection<EndpointMBean> mBeans = this.mBeanFactory.createMBeans( Collection<EndpointMBean> mBeans = this.mBeanFactory
this.endpointProvider.getEndpoints()); .createMBeans(this.endpointProvider.getEndpoints());
for (EndpointMBean mBean : mBeans) { for (EndpointMBean mBean : mBeans) {
objectNames.add(this.endpointMBeanRegistrar.registerEndpointMBean(mBean)); objectNames.add(this.endpointMBeanRegistrar.registerEndpointMBean(mBean));
} }
...@@ -122,13 +121,13 @@ class JmxEndpointExporter implements InitializingBean, DisposableBean { ...@@ -122,13 +121,13 @@ class JmxEndpointExporter implements InitializingBean, DisposableBean {
if (responseType.equals(String.class)) { if (responseType.equals(String.class)) {
return String.class; return String.class;
} }
if (responseType.isArray() || Collection.class.isAssignableFrom(responseType)) { if (responseType.isArray()
|| Collection.class.isAssignableFrom(responseType)) {
return List.class; return List.class;
} }
return Map.class; return Map.class;
} }
} }
} }
...@@ -55,7 +55,8 @@ public class EndpointEnablementProvider { ...@@ -55,7 +55,8 @@ public class EndpointEnablementProvider {
* @param endpointId the id of the endpoint * @param endpointId the id of the endpoint
* @param enabledByDefault whether the endpoint is enabled by default or not * @param enabledByDefault whether the endpoint is enabled by default or not
* @param endpointType the requested {@link EndpointType} * @param endpointType the requested {@link EndpointType}
* @return the {@link EndpointEnablement} of that endpoint for the specified {@link EndpointType} * @return the {@link EndpointEnablement} of that endpoint for the specified
* {@link EndpointType}
*/ */
public EndpointEnablement getEndpointEnablement(String endpointId, public EndpointEnablement getEndpointEnablement(String endpointId,
boolean enabledByDefault, EndpointType endpointType) { boolean enabledByDefault, EndpointType endpointType) {
...@@ -92,9 +93,8 @@ public class EndpointEnablementProvider { ...@@ -92,9 +93,8 @@ public class EndpointEnablementProvider {
// All endpoints specific attributes have been looked at. Checking default value // All endpoints specific attributes have been looked at. Checking default value
// for the endpoint // for the endpoint
if (!enabledByDefault) { if (!enabledByDefault) {
return new EndpointEnablement(false, return new EndpointEnablement(false, createDefaultEnablementMessage(
createDefaultEnablementMessage(endpointId, enabledByDefault, endpointId, enabledByDefault, endpointType));
endpointType));
} }
if (endpointType != null) { if (endpointType != null) {
...@@ -106,7 +106,8 @@ public class EndpointEnablementProvider { ...@@ -106,7 +106,8 @@ public class EndpointEnablementProvider {
} }
else { else {
// Check if there is a global tech required // Check if there is a global tech required
EndpointEnablement anyTechGeneralOutcome = getAnyTechSpecificOutcomeFor("all"); EndpointEnablement anyTechGeneralOutcome = getAnyTechSpecificOutcomeFor(
"all");
if (anyTechGeneralOutcome != null) { if (anyTechGeneralOutcome != null) {
return anyTechGeneralOutcome; return anyTechGeneralOutcome;
} }
......
...@@ -100,7 +100,7 @@ public class HealthWebEndpointExtension { ...@@ -100,7 +100,7 @@ public class HealthWebEndpointExtension {
public WebEndpointResponse<Health> getHealth() { public WebEndpointResponse<Health> getHealth() {
Health health = this.delegate.health(); Health health = this.delegate.health();
Integer status = getStatus(health); Integer status = getStatus(health);
return new WebEndpointResponse<Health>(health, status); return new WebEndpointResponse<>(health, status);
} }
private int getStatus(Health health) { private int getStatus(Health health) {
......
...@@ -23,7 +23,6 @@ import org.springframework.mock.env.MockEnvironment; ...@@ -23,7 +23,6 @@ import org.springframework.mock.env.MockEnvironment;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
/** /**
* Tests for {@link CachingConfigurationFactory}. * Tests for {@link CachingConfigurationFactory}.
* *
......
...@@ -196,7 +196,7 @@ public class EnvironmentEndpointTests { ...@@ -196,7 +196,7 @@ public class EnvironmentEndpointTests {
public void propertyWithTypeOtherThanStringShouldNotFail() { public void propertyWithTypeOtherThanStringShouldNotFail() {
StandardEnvironment environment = new StandardEnvironment(); StandardEnvironment environment = new StandardEnvironment();
MutablePropertySources propertySources = environment.getPropertySources(); MutablePropertySources propertySources = environment.getPropertySources();
Map<String, Object> source = new HashMap<String, Object>(); Map<String, Object> source = new HashMap<>();
source.put("foo", Collections.singletonMap("bar", "baz")); source.put("foo", Collections.singletonMap("bar", "baz"));
propertySources.addFirst(new MapPropertySource("test", source)); propertySources.addFirst(new MapPropertySource("test", source));
EnvironmentDescriptor env = new EnvironmentEndpoint(environment) EnvironmentDescriptor env = new EnvironmentEndpoint(environment)
......
...@@ -70,7 +70,7 @@ public class EnvironmentEndpointWebIntegrationTests { ...@@ -70,7 +70,7 @@ public class EnvironmentEndpointWebIntegrationTests {
@Test @Test
public void nestedPathWhenPlaceholderCannotBeResolvedShouldReturnUnresolvedProperty() public void nestedPathWhenPlaceholderCannotBeResolvedShouldReturnUnresolvedProperty()
throws Exception { throws Exception {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<>();
map.put("my.foo", "${my.bar}"); map.put("my.foo", "${my.bar}");
context.getEnvironment().getPropertySources() context.getEnvironment().getPropertySources()
.addFirst(new MapPropertySource("unresolved-placeholder", map)); .addFirst(new MapPropertySource("unresolved-placeholder", map));
...@@ -81,7 +81,7 @@ public class EnvironmentEndpointWebIntegrationTests { ...@@ -81,7 +81,7 @@ public class EnvironmentEndpointWebIntegrationTests {
@Test @Test
public void nestedPathWithSensitivePlaceholderShouldSanitize() throws Exception { public void nestedPathWithSensitivePlaceholderShouldSanitize() throws Exception {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<>();
map.put("my.foo", "${my.password}"); map.put("my.foo", "${my.password}");
map.put("my.password", "hello"); map.put("my.password", "hello");
context.getEnvironment().getPropertySources() context.getEnvironment().getPropertySources()
...@@ -94,7 +94,7 @@ public class EnvironmentEndpointWebIntegrationTests { ...@@ -94,7 +94,7 @@ public class EnvironmentEndpointWebIntegrationTests {
@Test @Test
public void nestedPathMatchedByRegexWhenPlaceholderCannotBeResolvedShouldReturnUnresolvedProperty() public void nestedPathMatchedByRegexWhenPlaceholderCannotBeResolvedShouldReturnUnresolvedProperty()
throws Exception { throws Exception {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<>();
map.put("my.foo", "${my.bar}"); map.put("my.foo", "${my.bar}");
context.getEnvironment().getPropertySources() context.getEnvironment().getPropertySources()
.addFirst(new MapPropertySource("unresolved-placeholder", map)); .addFirst(new MapPropertySource("unresolved-placeholder", map));
...@@ -108,7 +108,7 @@ public class EnvironmentEndpointWebIntegrationTests { ...@@ -108,7 +108,7 @@ public class EnvironmentEndpointWebIntegrationTests {
@Test @Test
public void nestedPathMatchedByRegexWithSensitivePlaceholderShouldSanitize() public void nestedPathMatchedByRegexWithSensitivePlaceholderShouldSanitize()
throws Exception { throws Exception {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<>();
map.put("my.foo", "${my.password}"); map.put("my.foo", "${my.password}");
map.put("my.password", "hello"); map.put("my.password", "hello");
context.getEnvironment().getPropertySources() context.getEnvironment().getPropertySources()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment