Browse Source

Rename spring.reactor.stacktrace-mode.enabled property

Closes gh-16537
pull/17049/head
Stephane Nicoll 7 years ago
parent
commit
f30e29a4ad
  1. 2
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/reactor/core/ReactorCoreAutoConfiguration.java
  2. 30
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/reactor/core/ReactorCoreProperties.java
  3. 72
      spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/reactor/core/ReactorCoreAutoConfigurationTests.java
  4. 2
      spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsPropertyDefaultsPostProcessor.java

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

@ -39,7 +39,7 @@ public class ReactorCoreAutoConfiguration { @@ -39,7 +39,7 @@ public class ReactorCoreAutoConfiguration {
@Autowired
protected void initialize(ReactorCoreProperties properties) {
if (properties.getStacktraceMode().isEnabled()) {
if (properties.isDebug()) {
Hooks.onOperatorDebug();
}
}

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

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2012-2017 the original author or authors.
* Copyright 2012-2019 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.
@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
package org.springframework.boot.autoconfigure.reactor.core;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
/**
* Properties for Reactor Core.
@ -27,25 +28,36 @@ import org.springframework.boot.context.properties.ConfigurationProperties; @@ -27,25 +28,36 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
@ConfigurationProperties(prefix = "spring.reactor")
public class ReactorCoreProperties {
/**
* Whether Reactor should collect stacktrace information at runtime.
*/
private boolean debug;
private final StacktraceMode stacktraceMode = new StacktraceMode();
public boolean isDebug() {
return this.debug;
}
public void setDebug(boolean debug) {
this.debug = debug;
}
public StacktraceMode getStacktraceMode() {
return this.stacktraceMode;
}
public static class StacktraceMode {
/**
* Whether Reactor should collect stacktrace information at runtime.
*/
private boolean enabled;
public class StacktraceMode {
@DeprecatedConfigurationProperty(replacement = "spring.reactor.debug")
@Deprecated
public boolean isEnabled() {
return this.enabled;
return isDebug();
}
@Deprecated
public void setEnabled(boolean enabled) {
this.enabled = enabled;
setDebug(enabled);
}
}

72
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/reactor/core/ReactorCoreAutoConfigurationTests.java

@ -0,0 +1,72 @@ @@ -0,0 +1,72 @@
/*
* Copyright 2012-2019 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.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.reactor.core;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Hooks;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.test.context.runner.ContextConsumer;
import org.springframework.test.util.ReflectionTestUtils;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link ReactorCoreAutoConfiguration}.
*
* @author Stephane Nicoll
*/
class ReactorCoreAutoConfigurationTests {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(ReactorCoreAutoConfiguration.class));
@BeforeEach
void resetDebugFlag() {
Hooks.resetOnOperatorDebug();
}
@Test
void debugOperatorIsDisabledByDefault() {
this.contextRunner.run(assertDebugOperator(false));
}
@Test
void debugOperatorIsSetWithProperty() {
this.contextRunner.withPropertyValues("spring.reactor.debug=true")
.run(assertDebugOperator(true));
}
@Test
@Deprecated
void debugOperatorIsSetWithDeprecatedProperty() {
this.contextRunner
.withPropertyValues("spring.reactor.stacktrace-mode.enabled=true")
.run(assertDebugOperator(true));
}
private ContextConsumer<AssertableApplicationContext> assertDebugOperator(
boolean expected) {
return (context) -> assertThat(
ReflectionTestUtils.getField(Hooks.class, "GLOBAL_TRACE"))
.isEqualTo(expected);
}
}

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

@ -73,7 +73,7 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro @@ -73,7 +73,7 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro
properties.put("spring.mvc.log-resolved-exception", "true");
properties.put("server.error.include-stacktrace", "ALWAYS");
properties.put("server.servlet.jsp.init-parameters.development", "true");
properties.put("spring.reactor.stacktrace-mode.enabled", "true");
properties.put("spring.reactor.debug", "true");
PROPERTIES = Collections.unmodifiableMap(properties);
}

Loading…
Cancel
Save