Commit 01558100 authored by Andy Wilkinson's avatar Andy Wilkinson

Do not attempt to use AprLifecycleListener in a native image

Closes gh-22485
parent 87990338
......@@ -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() {
AprLifecycleListener aprLifecycleListener = new AprLifecycleListener();
return AprLifecycleListener.isAprAvailable() ? new ArrayList<>(Arrays.asList(aprLifecycleListener))
: new ArrayList<>();
ArrayList<LifecycleListener> lifecycleListeners = new ArrayList<>();
if (!IN_NATIVE_IMAGE) {
AprLifecycleListener aprLifecycleListener = new AprLifecycleListener();
if (AprLifecycleListener.isAprAvailable()) {
lifecycleListeners.add(aprLifecycleListener);
}
}
return lifecycleListeners;
}
@Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment