From 7efbedc0dc54ceb8025739c3b2e1771d613b4112 Mon Sep 17 00:00:00 2001 From: Madhura Bhave Date: Tue, 25 Apr 2017 10:53:01 -0700 Subject: [PATCH] Use new configuration properties in devtools Update `spring-boot-devtools` to use the new configuration properties support. See gh-9000 --- .../env/DevToolsPropertyDefaultsPostProcessor.java | 6 ++---- .../client/LocalDebugPortAvailableCondition.java | 13 +++++-------- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java index b6118cf3bce..28ef8e409f0 100755 --- a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java +++ b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java @@ -21,7 +21,6 @@ import java.util.HashMap; import java.util.Map; import org.springframework.boot.SpringApplication; -import org.springframework.boot.bind.RelaxedPropertyResolver; import org.springframework.boot.devtools.restart.Restarter; import org.springframework.boot.env.EnvironmentPostProcessor; import org.springframework.core.Ordered; @@ -37,6 +36,7 @@ import org.springframework.core.env.PropertySource; * * @author Phillip Webb * @author Andy Wilkinson + * @author Madhura Bhave * @since 1.3.0 */ @Order(Ordered.LOWEST_PRECEDENCE) @@ -90,9 +90,7 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro } private boolean isRemoteRestartEnabled(Environment environment) { - RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment, - "spring.devtools.remote."); - return resolver.containsProperty("secret"); + return environment.containsProperty("spring.devtools.remote.secret"); } } diff --git a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/LocalDebugPortAvailableCondition.java b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/LocalDebugPortAvailableCondition.java index 5b8d6606f1a..d8f1e3051ab 100644 --- a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/LocalDebugPortAvailableCondition.java +++ b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/LocalDebugPortAvailableCondition.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,7 +21,6 @@ import javax.net.ServerSocketFactory; import org.springframework.boot.autoconfigure.condition.ConditionMessage; import org.springframework.boot.autoconfigure.condition.ConditionOutcome; import org.springframework.boot.autoconfigure.condition.SpringBootCondition; -import org.springframework.boot.bind.RelaxedPropertyResolver; import org.springframework.boot.devtools.autoconfigure.RemoteDevToolsProperties; import org.springframework.context.annotation.ConditionContext; import org.springframework.core.type.AnnotatedTypeMetadata; @@ -30,6 +29,7 @@ import org.springframework.core.type.AnnotatedTypeMetadata; * Condition used to check that the actual local port is available. * * @author Phillip Webb + * @author Madhura Bhave */ class LocalDebugPortAvailableCondition extends SpringBootCondition { @@ -38,12 +38,9 @@ class LocalDebugPortAvailableCondition extends SpringBootCondition { AnnotatedTypeMetadata metadata) { ConditionMessage.Builder message = ConditionMessage .forCondition("Local Debug Port Condition"); - RelaxedPropertyResolver resolver = new RelaxedPropertyResolver( - context.getEnvironment(), "spring.devtools.remote.debug."); - Integer port = resolver.getProperty("local-port", Integer.class); - if (port == null) { - port = RemoteDevToolsProperties.Debug.DEFAULT_LOCAL_PORT; - } + Integer port = context.getEnvironment().getProperty( + "spring.devtools.remote.debug.local-port", Integer.class, + RemoteDevToolsProperties.Debug.DEFAULT_LOCAL_PORT); if (isPortAvailable(port)) { return ConditionOutcome.match(message.foundExactly("local debug port")); }