Commit f30e29a4 authored by Stephane Nicoll's avatar Stephane Nicoll

Rename spring.reactor.stacktrace-mode.enabled property

Closes gh-16537
parent 090cc05e
...@@ -39,7 +39,7 @@ public class ReactorCoreAutoConfiguration { ...@@ -39,7 +39,7 @@ public class ReactorCoreAutoConfiguration {
@Autowired @Autowired
protected void initialize(ReactorCoreProperties properties) { protected void initialize(ReactorCoreProperties properties) {
if (properties.getStacktraceMode().isEnabled()) { if (properties.isDebug()) {
Hooks.onOperatorDebug(); Hooks.onOperatorDebug();
} }
} }
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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; package org.springframework.boot.autoconfigure.reactor.core;
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
/** /**
* Properties for Reactor Core. * 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") @ConfigurationProperties(prefix = "spring.reactor")
public class ReactorCoreProperties { public class ReactorCoreProperties {
/**
* Whether Reactor should collect stacktrace information at runtime.
*/
private boolean debug;
private final StacktraceMode stacktraceMode = new StacktraceMode(); private final StacktraceMode stacktraceMode = new StacktraceMode();
public boolean isDebug() {
return this.debug;
}
public void setDebug(boolean debug) {
this.debug = debug;
}
public StacktraceMode getStacktraceMode() { public StacktraceMode getStacktraceMode() {
return this.stacktraceMode; return this.stacktraceMode;
} }
public static class StacktraceMode { public class StacktraceMode {
/**
* Whether Reactor should collect stacktrace information at runtime.
*/
private boolean enabled;
@DeprecatedConfigurationProperty(replacement = "spring.reactor.debug")
@Deprecated
public boolean isEnabled() { public boolean isEnabled() {
return this.enabled; return isDebug();
} }
@Deprecated
public void setEnabled(boolean enabled) { public void setEnabled(boolean enabled) {
this.enabled = enabled; setDebug(enabled);
} }
} }
......
/*
* 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);
}
}
...@@ -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("spring.mvc.log-resolved-exception", "true");
properties.put("server.error.include-stacktrace", "ALWAYS"); properties.put("server.error.include-stacktrace", "ALWAYS");
properties.put("server.servlet.jsp.init-parameters.development", "true"); 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); PROPERTIES = Collections.unmodifiableMap(properties);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment