Merge branch '2.1.x'

pull/16419/head
Andy Wilkinson 6 years ago
commit 512fbae715

@ -22,7 +22,6 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.apache.catalina.Context;
@ -67,8 +66,7 @@ public class TomcatReactiveWebServerFactory extends AbstractReactiveWebServerFac
private List<Valve> engineValves = new ArrayList<>();
private List<LifecycleListener> contextLifecycleListeners = new ArrayList<>(
Collections.singleton(new AprLifecycleListener()));
private List<LifecycleListener> contextLifecycleListeners = getDefaultLifecycleListeners();
private List<TomcatContextCustomizer> tomcatContextCustomizers = new ArrayList<>();
@ -95,6 +93,13 @@ public class TomcatReactiveWebServerFactory extends AbstractReactiveWebServerFac
super(port);
}
private static List<LifecycleListener> getDefaultLifecycleListeners() {
AprLifecycleListener aprLifecycleListener = new AprLifecycleListener();
return AprLifecycleListener.isAprAvailable()
? new ArrayList<>(Arrays.asList(aprLifecycleListener))
: new ArrayList<>();
}
@Override
public WebServer getWebServer(HttpHandler httpHandler) {
Tomcat tomcat = new Tomcat();

@ -111,8 +111,7 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto
private List<Valve> contextValves = new ArrayList<>();
private List<LifecycleListener> contextLifecycleListeners = new ArrayList<>(
Collections.singleton(new AprLifecycleListener()));
private List<LifecycleListener> contextLifecycleListeners = getDefaultLifecycleListeners();
private List<TomcatContextCustomizer> tomcatContextCustomizers = new ArrayList<>();
@ -155,6 +154,13 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto
super(contextPath, port);
}
private static List<LifecycleListener> getDefaultLifecycleListeners() {
AprLifecycleListener aprLifecycleListener = new AprLifecycleListener();
return AprLifecycleListener.isAprAvailable()
? new ArrayList<>(Arrays.asList(aprLifecycleListener))
: new ArrayList<>();
}
@Override
public WebServer getWebServer(ServletContextInitializer... initializers) {
Tomcat tomcat = new Tomcat();

@ -82,9 +82,14 @@ public class TomcatReactiveWebServerFactoryTests
@Test
public void defaultTomcatListeners() {
TomcatReactiveWebServerFactory factory = getFactory();
if (AprLifecycleListener.isAprAvailable()) {
assertThat(factory.getContextLifecycleListeners()).hasSize(1).first()
.isInstanceOf(AprLifecycleListener.class);
}
else {
assertThat(factory.getContextLifecycleListeners()).isEmpty();
}
}
@Test
public void tomcatListeners() {

@ -134,9 +134,14 @@ public class TomcatServletWebServerFactoryTests
@Test
public void defaultTomcatListeners() {
TomcatServletWebServerFactory factory = getFactory();
if (AprLifecycleListener.isAprAvailable()) {
assertThat(factory.getContextLifecycleListeners()).hasSize(1).first()
.isInstanceOf(AprLifecycleListener.class);
}
else {
assertThat(factory.getContextLifecycleListeners()).isEmpty();
}
}
@Test
public void tomcatListeners() {

Loading…
Cancel
Save