Provide Reactor 3 auto-configuration
This commit provides auto-configuration for the Reactor Core 3 library. A new configuration namespace, "spring.reactor" allows to configure hooks on operators, like "spring.reactor.stacktrace-mode.enabled". This property is enabled automatically by devtools, since it improves the developer experience and provides full stacktrace information when exceptions occur (but at a performance cost). Fixes gh-7302
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://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 reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Hooks;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* {@link EnableAutoConfiguration Auto-configuration} for Reactor Core.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass({Mono.class, Flux.class})
|
||||
@EnableConfigurationProperties(ReactorCoreProperties.class)
|
||||
public class ReactorCoreAutoConfiguration {
|
||||
|
||||
@Autowired
|
||||
protected void initialize(ReactorCoreProperties properties) {
|
||||
if (properties.getStacktraceMode().isEnabled()) {
|
||||
Hooks.onOperator(h -> h.operatorStacktrace());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://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.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
/**
|
||||
* Properties for Reactor Core.
|
||||
*
|
||||
* @author Brian Clozel
|
||||
* @since 2.0.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "spring.reactor")
|
||||
public class ReactorCoreProperties {
|
||||
|
||||
private final StacktraceMode stacktraceMode = new StacktraceMode();
|
||||
|
||||
public StacktraceMode getStacktraceMode() {
|
||||
return this.stacktraceMode;
|
||||
}
|
||||
|
||||
public static class StacktraceMode {
|
||||
|
||||
/**
|
||||
* Set whether Reactor should collect stacktrace information at runtime.
|
||||
*/
|
||||
private boolean enabled;
|
||||
|
||||
public boolean isEnabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -85,6 +85,7 @@ org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfigura
|
||||
org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.mustache.MustacheAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.reactor.core.ReactorCoreAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.security.SecurityFilterAutoConfiguration,\
|
||||
org.springframework.boot.autoconfigure.security.FallbackWebSecurityAutoConfiguration,\
|
||||
|
||||
@@ -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.
|
||||
@@ -57,6 +57,7 @@ public class DevToolsPropertyDefaultsPostProcessor implements EnvironmentPostPro
|
||||
properties.put("spring.template.provider.cache", "false");
|
||||
properties.put("spring.mvc.log-resolved-exception", "true");
|
||||
properties.put("server.jsp-servlet.init-parameters.development", "true");
|
||||
properties.put("spring.reactor.stacktrace-mode.enabled", "true");
|
||||
PROPERTIES = Collections.unmodifiableMap(properties);
|
||||
}
|
||||
|
||||
|
||||
@@ -119,6 +119,9 @@ content into your application; rather pick only the properties that you need.
|
||||
spring.messages.encoding=UTF-8 # Message bundles encoding.
|
||||
spring.messages.fallback-to-system-locale=true # Set whether to fall back to the system Locale if no files for a specific Locale have been found.
|
||||
|
||||
# REACTOR
|
||||
spring.reactor.stacktrace-mode.enabled=true # Set whether Reactor should collect stacktrace information at runtime.
|
||||
|
||||
# OUTPUT
|
||||
spring.output.ansi.enabled=detect # Configure the ANSI output.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user