Prefer servlet to reactive when Jersey and WebFlux are both available

Closes gh-13521
This commit is contained in:
Andy Wilkinson 2018-06-20 10:10:35 +01:00
parent 814e90805e
commit e1774672af
2 changed files with 8 additions and 2 deletions

View File

@ -86,6 +86,8 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
private static final String MVC_WEB_ENVIRONMENT_CLASS = "org.springframework." private static final String MVC_WEB_ENVIRONMENT_CLASS = "org.springframework."
+ "web.servlet.DispatcherServlet"; + "web.servlet.DispatcherServlet";
private static final String JERSEY_WEB_ENVIRONMENT_CLASS = "org.glassfish.jersey.server.ResourceConfig";
private static final String ACTIVATE_SERVLET_LISTENER = "org.springframework.test." private static final String ACTIVATE_SERVLET_LISTENER = "org.springframework.test."
+ "context.web.ServletTestExecutionListener.activateListener"; + "context.web.ServletTestExecutionListener.activateListener";
@ -192,7 +194,8 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
private WebApplicationType deduceWebApplicationType() { private WebApplicationType deduceWebApplicationType() {
if (ClassUtils.isPresent(REACTIVE_WEB_ENVIRONMENT_CLASS, null) if (ClassUtils.isPresent(REACTIVE_WEB_ENVIRONMENT_CLASS, null)
&& !ClassUtils.isPresent(MVC_WEB_ENVIRONMENT_CLASS, null)) { && !ClassUtils.isPresent(MVC_WEB_ENVIRONMENT_CLASS, null)
&& !ClassUtils.isPresent(JERSEY_WEB_ENVIRONMENT_CLASS, null)) {
return WebApplicationType.REACTIVE; return WebApplicationType.REACTIVE;
} }
for (String className : WEB_ENVIRONMENT_CLASSES) { for (String className : WEB_ENVIRONMENT_CLASSES) {

View File

@ -183,6 +183,8 @@ public class SpringApplication {
private static final String MVC_WEB_ENVIRONMENT_CLASS = "org.springframework." private static final String MVC_WEB_ENVIRONMENT_CLASS = "org.springframework."
+ "web.servlet.DispatcherServlet"; + "web.servlet.DispatcherServlet";
private static final String JERSEY_WEB_ENVIRONMENT_CLASS = "org.glassfish.jersey.server.ResourceConfig";
/** /**
* Default banner location. * Default banner location.
*/ */
@ -271,7 +273,8 @@ public class SpringApplication {
private WebApplicationType deduceWebApplicationType() { private WebApplicationType deduceWebApplicationType() {
if (ClassUtils.isPresent(REACTIVE_WEB_ENVIRONMENT_CLASS, null) if (ClassUtils.isPresent(REACTIVE_WEB_ENVIRONMENT_CLASS, null)
&& !ClassUtils.isPresent(MVC_WEB_ENVIRONMENT_CLASS, null)) { && !ClassUtils.isPresent(MVC_WEB_ENVIRONMENT_CLASS, null)
&& !ClassUtils.isPresent(JERSEY_WEB_ENVIRONMENT_CLASS, null)) {
return WebApplicationType.REACTIVE; return WebApplicationType.REACTIVE;
} }
for (String className : WEB_ENVIRONMENT_CLASSES) { for (String className : WEB_ENVIRONMENT_CLASSES) {