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";
private static final boolean IN_NATIVE_IMAGE = System.getProperty("org.graalvm.nativeimage.imagecode") != null;
private File baseDirectory;
private List<Valve> engineValves = new ArrayList<>();
@ -164,9 +166,14 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto
}
private static List<LifecycleListener> getDefaultLifecycleListeners() {
ArrayList<LifecycleListener> lifecycleListeners = new ArrayList<>();
if (!IN_NATIVE_IMAGE) {
AprLifecycleListener aprLifecycleListener = new AprLifecycleListener();
return AprLifecycleListener.isAprAvailable() ? new ArrayList<>(Arrays.asList(aprLifecycleListener))
: new ArrayList<>();
if (AprLifecycleListener.isAprAvailable()) {
lifecycleListeners.add(aprLifecycleListener);
}
}
return lifecycleListeners;
}
@Override

Loading…
Cancel
Save