Skip to content

Commit 09dd986

Browse files
snicollwilkinsona
authored andcommitted
Rename spring.reactor.stacktrace-mode.enabled property
Closes spring-projectsgh-16537
1 parent e0142e7 commit 09dd986

File tree

4 files changed

+95
-11
lines changed

4 files changed

+95
-11
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/reactor/core/ReactorCoreAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class ReactorCoreAutoConfiguration {
3939

4040
@Autowired
4141
protected void initialize(ReactorCoreProperties properties) {
42-
if (properties.getStacktraceMode().isEnabled()) {
42+
if (properties.isDebug()) {
4343
Hooks.onOperatorDebug();
4444
}
4545
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/reactor/core/ReactorCoreProperties.java

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2017 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,6 +17,7 @@
1717
package org.springframework.boot.autoconfigure.reactor.core;
1818

1919
import org.springframework.boot.context.properties.ConfigurationProperties;
20+
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
2021

2122
/**
2223
* Properties for Reactor Core.
@@ -27,25 +28,36 @@
2728
@ConfigurationProperties(prefix = "spring.reactor")
2829
public class ReactorCoreProperties {
2930

31+
/**
32+
* Whether Reactor should collect stacktrace information at runtime.
33+
*/
34+
private boolean debug;
35+
3036
private final StacktraceMode stacktraceMode = new StacktraceMode();
3137

38+
public boolean isDebug() {
39+
return this.debug;
40+
}
41+
42+
public void setDebug(boolean debug) {
43+
this.debug = debug;
44+
}
45+
3246
public StacktraceMode getStacktraceMode() {
3347
return this.stacktraceMode;
3448
}
3549

36-
public static class StacktraceMode {
37-
38-
/**
39-
* Whether Reactor should collect stacktrace information at runtime.
40-
*/
41-
private boolean enabled;
50+
public class StacktraceMode {
4251

52+
@DeprecatedConfigurationProperty(replacement = "spring.reactor.debug")
53+
@Deprecated
4354
public boolean isEnabled() {
44-
return this.enabled;
55+
return isDebug();
4556
}
4657

58+
@Deprecated
4759
public void setEnabled(boolean enabled) {
48-
this.enabled = enabled;
60+
setDebug(enabled);
4961
}
5062

5163
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright 2012-2019 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.autoconfigure.reactor.core;
18+
19+
import org.junit.jupiter.api.BeforeEach;
20+
import org.junit.jupiter.api.Test;
21+
import reactor.core.publisher.Hooks;
22+
23+
import org.springframework.boot.autoconfigure.AutoConfigurations;
24+
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
25+
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
26+
import org.springframework.boot.test.context.runner.ContextConsumer;
27+
import org.springframework.test.util.ReflectionTestUtils;
28+
29+
import static org.assertj.core.api.Assertions.assertThat;
30+
31+
/**
32+
* Tests for {@link ReactorCoreAutoConfiguration}.
33+
*
34+
* @author Stephane Nicoll
35+
*/
36+
class ReactorCoreAutoConfigurationTests {
37+
38+
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
39+
.withConfiguration(AutoConfigurations.of(ReactorCoreAutoConfiguration.class));
40+
41+
@BeforeEach
42+
void resetDebugFlag() {
43+
Hooks.resetOnOperatorDebug();
44+
}
45+
46+
@Test
47+
void debugOperatorIsDisabledByDefault() {
48+
this.contextRunner.run(assertDebugOperator(false));
49+
}
50+
51+
@Test
52+
void debugOperatorIsSetWithProperty() {
53+
this.contextRunner.withPropertyValues("spring.reactor.debug=true")
54+
.run(assertDebugOperator(true));
55+
}
56+
57+
@Test
58+
@Deprecated
59+
void debugOperatorIsSetWithDeprecatedProperty() {
60+
this.contextRunner
61+
.withPropertyValues("spring.reactor.stacktrace-mode.enabled=true")
62+
.run(assertDebugOperator(true));
63+
}
64+
65+
private ContextConsumer<AssertableApplicationContext> assertDebugOperator(
66+
boolean expected) {
67+
return (context) -> assertThat(
68+
ReflectionTestUtils.getField(Hooks.class, "GLOBAL_TRACE"))
69+
.isEqualTo(expected);
70+
}
71+
72+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro
7373
properties.put("spring.mvc.log-resolved-exception", "true");
7474
properties.put("server.error.include-stacktrace", "ALWAYS");
7575
properties.put("server.servlet.jsp.init-parameters.development", "true");
76-
properties.put("spring.reactor.stacktrace-mode.enabled", "true");
76+
properties.put("spring.reactor.debug", "true");
7777
PROPERTIES = Collections.unmodifiableMap(properties);
7878
}
7979

0 commit comments

Comments
 (0)