diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpoint.java index c774ce1ab9..0ede3e749f 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpoint.java @@ -68,17 +68,19 @@ public class LoggersMvcEndpoint extends EndpointMvcAdapter { // disabled return getDisabledResponse(); } - LogLevel logLevel; try { - String level = configuration.get("configuredLevel"); - logLevel = level == null ? null : LogLevel.valueOf(level.toUpperCase()); + LogLevel logLevel = getLogLevel(configuration); + this.delegate.setLogLevel(name, logLevel); + return ResponseEntity.ok().build(); } catch (IllegalArgumentException ex) { return ResponseEntity.badRequest().build(); } + } - this.delegate.setLogLevel(name, logLevel); - return ResponseEntity.ok().build(); + private LogLevel getLogLevel(Map configuration) { + String level = configuration.get("configuredLevel"); + return (level == null ? null : LogLevel.valueOf(level.toUpperCase())); } } diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/TraceWebFilterAutoConfigurationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/TraceWebFilterAutoConfigurationTests.java index 3e232b42de..72acb33e5a 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/TraceWebFilterAutoConfigurationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/TraceWebFilterAutoConfigurationTests.java @@ -66,7 +66,7 @@ public class TraceWebFilterAutoConfigurationTests { public void skipsFilterIfPropertyDisabled() throws Exception { load("endpoints.trace.filter.enabled:false"); assertThat(this.context.getBeansOfType(WebRequestTraceFilter.class).size()) - .isEqualTo(0); + .isEqualTo(0); } private void load(String... environment) { @@ -74,16 +74,16 @@ public class TraceWebFilterAutoConfigurationTests { } private void load(Class config, String... environment) { - AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(); - EnvironmentTestUtils.addEnvironment(ctx, environment); + AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); + EnvironmentTestUtils.addEnvironment(context, environment); if (config != null) { - ctx.register(config); + context.register(config); } - ctx.register(PropertyPlaceholderAutoConfiguration.class, - TraceRepositoryAutoConfiguration.class, - TraceWebFilterAutoConfiguration.class); - ctx.refresh(); - this.context = ctx; + context.register(PropertyPlaceholderAutoConfiguration.class, + TraceRepositoryAutoConfiguration.class, + TraceWebFilterAutoConfiguration.class); + context.refresh(); + this.context = context; } @Configuration diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.java index 01fad73fc0..9feba19dad 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.java @@ -66,8 +66,8 @@ public class ValidationAutoConfiguration { } private static boolean determineProxyTargetClass(Environment environment) { - RelaxedPropertyResolver resolver = new RelaxedPropertyResolver( - environment, "spring.aop."); + RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment, + "spring.aop."); Boolean value = resolver.getProperty("proxyTargetClass", Boolean.class); return (value != null ? value : true); } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfigurationTests.java index af8a13a68e..1ea207316c 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfigurationTests.java @@ -78,12 +78,12 @@ public class ValidationAutoConfigurationTests { @Test public void validationCanBeConfiguredToUseJdkProxy() { - load(AnotherSampleServiceConfiguration.class, "spring.aop.proxy-target-class=false"); + load(AnotherSampleServiceConfiguration.class, + "spring.aop.proxy-target-class=false"); assertThat(this.context.getBeansOfType(Validator.class)).hasSize(1); assertThat(this.context.getBeansOfType(DefaultAnotherSampleService.class)) - .isEmpty(); - AnotherSampleService service = this.context - .getBean(AnotherSampleService.class); + .isEmpty(); + AnotherSampleService service = this.context.getBean(AnotherSampleService.class); service.doSomething(42); this.thrown.expect(ConstraintViolationException.class); service.doSomething(2);