From e1774672af07f2333b805ff5dd5ededed0efa944 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 20 Jun 2018 10:10:35 +0100 Subject: [PATCH] Prefer servlet to reactive when Jersey and WebFlux are both available Closes gh-13521 --- .../boot/test/context/SpringBootTestContextBootstrapper.java | 5 ++++- .../java/org/springframework/boot/SpringApplication.java | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextBootstrapper.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextBootstrapper.java index d2e00ff24f7..3ee521bed71 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextBootstrapper.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextBootstrapper.java @@ -86,6 +86,8 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr private static final String MVC_WEB_ENVIRONMENT_CLASS = "org.springframework." + "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." + "context.web.ServletTestExecutionListener.activateListener"; @@ -192,7 +194,8 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr private WebApplicationType deduceWebApplicationType() { 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; } for (String className : WEB_ENVIRONMENT_CLASSES) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java index e530d7d8786..b6cfabb6ac4 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java @@ -183,6 +183,8 @@ public class SpringApplication { private static final String MVC_WEB_ENVIRONMENT_CLASS = "org.springframework." + "web.servlet.DispatcherServlet"; + private static final String JERSEY_WEB_ENVIRONMENT_CLASS = "org.glassfish.jersey.server.ResourceConfig"; + /** * Default banner location. */ @@ -271,7 +273,8 @@ public class SpringApplication { private WebApplicationType deduceWebApplicationType() { 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; } for (String className : WEB_ENVIRONMENT_CLASSES) {