Rationalize the Reactor autoconfig
It didn't make sense not to do anything at all if a Reactor @Bean was detected, so now we only back off creating the rootReactor if one is present.
This commit is contained in:
@@ -35,11 +35,11 @@ import reactor.spring.context.config.EnableReactor;
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnClass(EnableReactor.class)
|
||||
@ConditionalOnMissingBean(Reactor.class)
|
||||
@AutoConfigureAfter(WebMvcAutoConfiguration.class)
|
||||
public class ReactorAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean(Reactor.class)
|
||||
public Reactor rootReactor(Environment environment) {
|
||||
return environment.getRootReactor();
|
||||
}
|
||||
|
||||
@@ -16,12 +16,16 @@
|
||||
|
||||
package org.springframework.boot.autoconfigure.reactor;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
import reactor.core.Environment;
|
||||
import reactor.core.Reactor;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import reactor.core.spec.Reactors;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -38,4 +42,21 @@ public class ReactorAutoConfigurationTests {
|
||||
this.context.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void customReactor() {
|
||||
this.context.register(TestConfiguration.class, ReactorAutoConfiguration.class);
|
||||
this.context.refresh();
|
||||
assertNotNull(this.context.getBean(Reactor.class));
|
||||
this.context.close();
|
||||
}
|
||||
|
||||
@Configuration
|
||||
protected static class TestConfiguration {
|
||||
|
||||
@Bean
|
||||
public Reactor reactor(Environment env) {
|
||||
return Reactors.reactor().env(env).dispatcher(Environment.RING_BUFFER).get();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user