-
Notifications
You must be signed in to change notification settings - Fork 41.6k
Closed
Description
Affects versions: 2.6.2
If you create Spring Boot application with spring-boot-starter-web and spring-boot-starter-webflux depdencencies, but in test/resources/application.properties declare:
spring.main.web-application-type=reactive
and create test:
@SpringBootTest
class ReactiveOrServletApplicationTests {
@Autowired(required = false)
private org.springframework.boot.web.servlet.error.ErrorAttributes errorAttributesServlet;
@Autowired(required = false)
private org.springframework.boot.web.reactive.error.ErrorAttributes errorAttributesReactive;
@Test
void contextLoads() {
assertThat(errorAttributesServlet).isNull();
assertThat(errorAttributesReactive).isNotNull();
}
}assertions will fail - Spring will create Servlet beans and ignore Reactive beans. Please see report:
ErrorWebFluxAutoConfiguration:
Did not match:
- not a reactive web application (OnWebApplicationCondition)
Matched:
- @ConditionalOnClass found required class 'org.springframework.web.reactive.config.WebFluxConfigurer' (OnClassCondition)
ErrorMvcAutoConfiguration matched:
- @ConditionalOnClass found required classes 'javax.servlet.Servlet', 'org.springframework.web.servlet.DispatcherServlet' (OnClassCondition)
- found 'session' scope (OnWebApplicationCondition)
That's somehow similar to #29169 Here a reason is evaluation:
Lines 133 to 136 in 4095096
| String[] scopes = context.getBeanFactory().getRegisteredScopeNames(); | |
| if (ObjectUtils.containsElement(scopes, "session")) { | |
| return ConditionOutcome.match(message.foundExactly("'session' scope")); | |
| } |
GenericWebApplicationContext is used as ConfigurableApplicationContextMetadata
Metadata
Assignees
Labels
type: bugA general bugA general bug