Do not attempt to use AprLifecycleListener in a native image

Closes gh-22485
pull/22499/head
Andy Wilkinson 4 years ago
parent 8799033801
commit 01558100d1

@ -110,6 +110,8 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto
*/ */
public static final String DEFAULT_PROTOCOL = "org.apache.coyote.http11.Http11NioProtocol"; public static final String DEFAULT_PROTOCOL = "org.apache.coyote.http11.Http11NioProtocol";
private static final boolean IN_NATIVE_IMAGE = System.getProperty("org.graalvm.nativeimage.imagecode") != null;
private File baseDirectory; private File baseDirectory;
private List<Valve> engineValves = new ArrayList<>(); private List<Valve> engineValves = new ArrayList<>();
@ -164,9 +166,14 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto
} }
private static List<LifecycleListener> getDefaultLifecycleListeners() { private static List<LifecycleListener> getDefaultLifecycleListeners() {
AprLifecycleListener aprLifecycleListener = new AprLifecycleListener(); ArrayList<LifecycleListener> lifecycleListeners = new ArrayList<>();
return AprLifecycleListener.isAprAvailable() ? new ArrayList<>(Arrays.asList(aprLifecycleListener)) if (!IN_NATIVE_IMAGE) {
: new ArrayList<>(); AprLifecycleListener aprLifecycleListener = new AprLifecycleListener();
if (AprLifecycleListener.isAprAvailable()) {
lifecycleListeners.add(aprLifecycleListener);
}
}
return lifecycleListeners;
} }
@Override @Override

Loading…
Cancel
Save