Skip to content

Commit 7c8bf48

Browse files
izeyewilkinsona
authored andcommitted
Polish DevToolsEnablementDeducer and OnEnabledDevToolsCondition
See gh-16732
1 parent ca51609 commit 7c8bf48

File tree

8 files changed

+23
-21
lines changed

8 files changed

+23
-21
lines changed
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@
2121
import java.util.Set;
2222

2323
/**
24-
* Utility to deduce if Devtools should be enabled in the current context.
24+
* Utility to deduce if DevTools should be enabled in the current context.
2525
*
2626
* @author Madhura Bhave
27+
* @since 2.2.0
2728
*/
28-
public final class DevtoolsEnablementDeducer {
29+
public final class DevToolsEnablementDeducer {
2930

3031
private static final Set<String> SKIPPED_STACK_ELEMENTS;
3132

@@ -38,7 +39,7 @@ public final class DevtoolsEnablementDeducer {
3839
SKIPPED_STACK_ELEMENTS = Collections.unmodifiableSet(skipped);
3940
}
4041

41-
private DevtoolsEnablementDeducer() {
42+
private DevToolsEnablementDeducer() {
4243
}
4344

4445
/**

spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/DevToolsDataSourceAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
* @since 1.3.3
5656
*/
5757
@AutoConfigureAfter(DataSourceAutoConfiguration.class)
58-
@Conditional({ OnEnabledDevtoolsCondition.class, DevToolsDataSourceCondition.class })
58+
@Conditional({ OnEnabledDevToolsCondition.class, DevToolsDataSourceCondition.class })
5959
@Configuration(proxyBeanMethods = false)
6060
public class DevToolsDataSourceAutoConfiguration {
6161

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,23 @@
1919
import org.springframework.boot.autoconfigure.condition.ConditionMessage;
2020
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
2121
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
22-
import org.springframework.boot.devtools.DevtoolsEnablementDeducer;
22+
import org.springframework.boot.devtools.DevToolsEnablementDeducer;
2323
import org.springframework.context.annotation.ConditionContext;
2424
import org.springframework.core.type.AnnotatedTypeMetadata;
2525

2626
/**
2727
* A condition that checks if DevTools should be enabled.
2828
*
2929
* @author Madhura Bhave
30+
* @since 2.2.0
3031
*/
31-
public class OnEnabledDevtoolsCondition extends SpringBootCondition {
32+
public class OnEnabledDevToolsCondition extends SpringBootCondition {
3233

3334
@Override
3435
public ConditionOutcome getMatchOutcome(ConditionContext context,
3536
AnnotatedTypeMetadata metadata) {
3637
ConditionMessage.Builder message = ConditionMessage.forCondition("Devtools");
37-
boolean shouldEnable = DevtoolsEnablementDeducer
38+
boolean shouldEnable = DevToolsEnablementDeducer
3839
.shouldEnable(Thread.currentThread());
3940
if (!shouldEnable) {
4041
return ConditionOutcome.noMatch(

spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/RemoteDevToolsAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
* @since 1.3.0
5757
*/
5858
@Configuration(proxyBeanMethods = false)
59-
@Conditional(OnEnabledDevtoolsCondition.class)
59+
@Conditional(OnEnabledDevToolsCondition.class)
6060
@ConditionalOnProperty(prefix = "spring.devtools.remote", name = "secret")
6161
@ConditionalOnClass({ Filter.class, ServerHttpRequest.class })
6262
@EnableConfigurationProperties({ ServerProperties.class, DevToolsProperties.class })

spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsHomePropertiesPostProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import java.util.Properties;
2222

2323
import org.springframework.boot.SpringApplication;
24-
import org.springframework.boot.devtools.DevtoolsEnablementDeducer;
24+
import org.springframework.boot.devtools.DevToolsEnablementDeducer;
2525
import org.springframework.boot.env.EnvironmentPostProcessor;
2626
import org.springframework.core.env.ConfigurableEnvironment;
2727
import org.springframework.core.env.PropertiesPropertySource;
@@ -44,7 +44,7 @@ public class DevToolsHomePropertiesPostProcessor implements EnvironmentPostProce
4444
@Override
4545
public void postProcessEnvironment(ConfigurableEnvironment environment,
4646
SpringApplication application) {
47-
if (DevtoolsEnablementDeducer.shouldEnable(Thread.currentThread())) {
47+
if (DevToolsEnablementDeducer.shouldEnable(Thread.currentThread())) {
4848
File home = getHomeFolder();
4949
File propertyFile = (home != null) ? new File(home, FILE_NAME) : null;
5050
if (propertyFile != null && propertyFile.exists() && propertyFile.isFile()) {

spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import org.apache.commons.logging.Log;
2424

2525
import org.springframework.boot.SpringApplication;
26-
import org.springframework.boot.devtools.DevtoolsEnablementDeducer;
26+
import org.springframework.boot.devtools.DevToolsEnablementDeducer;
2727
import org.springframework.boot.devtools.logger.DevToolsLogFactory;
2828
import org.springframework.boot.devtools.restart.Restarter;
2929
import org.springframework.boot.env.EnvironmentPostProcessor;
@@ -80,7 +80,7 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro
8080
@Override
8181
public void postProcessEnvironment(ConfigurableEnvironment environment,
8282
SpringApplication application) {
83-
if (DevtoolsEnablementDeducer.shouldEnable(Thread.currentThread())
83+
if (DevToolsEnablementDeducer.shouldEnable(Thread.currentThread())
8484
&& isLocalApplication(environment)) {
8585
if (canAddProperties(environment)) {
8686
logger.info("Devtools property defaults active! Set '" + ENABLED

spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/DefaultRestartInitializer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
import java.net.URL;
2020

21-
import org.springframework.boot.devtools.DevtoolsEnablementDeducer;
21+
import org.springframework.boot.devtools.DevToolsEnablementDeducer;
2222

2323
/**
2424
* Default {@link RestartInitializer} that only enable initial restart when running a
@@ -36,7 +36,7 @@ public URL[] getInitialUrls(Thread thread) {
3636
if (!isMain(thread)) {
3737
return null;
3838
}
39-
if (!DevtoolsEnablementDeducer.shouldEnable(thread)) {
39+
if (!DevToolsEnablementDeducer.shouldEnable(thread)) {
4040
return null;
4141
}
4242
return getUrls(thread);
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
import static org.assertj.core.api.Assertions.assertThat;
2828

2929
/**
30-
* Tests for {@link OnEnabledDevtoolsCondition}.
30+
* Tests for {@link OnEnabledDevToolsCondition}.
3131
*
3232
* @author Madhura Bhave
3333
*/
34-
public class OnEnabledDevtoolsConditionTests {
34+
public class OnEnabledDevToolsConditionTests {
3535

3636
private AnnotationConfigApplicationContext context;
3737

@@ -44,8 +44,8 @@ public void setup() {
4444
@Test
4545
public void outcomeWhenDevtoolsShouldBeEnabledIsTrueShouldMatch() throws Exception {
4646
Thread thread = new Thread(() -> {
47-
OnEnabledDevtoolsConditionTests.this.context.refresh();
48-
assertThat(OnEnabledDevtoolsConditionTests.this.context.containsBean("test"))
47+
OnEnabledDevToolsConditionTests.this.context.refresh();
48+
assertThat(OnEnabledDevToolsConditionTests.this.context.containsBean("test"))
4949
.isTrue();
5050
});
5151
thread.start();
@@ -54,16 +54,16 @@ public void outcomeWhenDevtoolsShouldBeEnabledIsTrueShouldMatch() throws Excepti
5454

5555
@Test
5656
public void outcomeWhenDevtoolsShouldBeEnabledIsFalseShouldNotMatch() {
57-
OnEnabledDevtoolsConditionTests.this.context.refresh();
58-
assertThat(OnEnabledDevtoolsConditionTests.this.context.containsBean("test"))
57+
OnEnabledDevToolsConditionTests.this.context.refresh();
58+
assertThat(OnEnabledDevToolsConditionTests.this.context.containsBean("test"))
5959
.isFalse();
6060
}
6161

6262
@Configuration(proxyBeanMethods = false)
6363
static class TestConfiguration {
6464

6565
@Bean
66-
@Conditional(OnEnabledDevtoolsCondition.class)
66+
@Conditional(OnEnabledDevToolsCondition.class)
6767
public String test() {
6868
return "hello";
6969
}

0 commit comments

Comments
 (0)