Commit 55e3ca66 authored by Andy Wilkinson's avatar Andy Wilkinson

Replace native image system property with call to NativeDetector

Closes gh-25303
parent dcbc3a29
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -29,6 +29,7 @@ import org.springframework.boot.context.event.ApplicationReadyEvent; ...@@ -29,6 +29,7 @@ import org.springframework.boot.context.event.ApplicationReadyEvent;
import org.springframework.boot.context.event.SpringApplicationEvent; import org.springframework.boot.context.event.SpringApplicationEvent;
import org.springframework.boot.context.logging.LoggingApplicationListener; import org.springframework.boot.context.logging.LoggingApplicationListener;
import org.springframework.context.ApplicationListener; import org.springframework.context.ApplicationListener;
import org.springframework.core.NativeDetector;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.format.support.DefaultFormattingConversionService; import org.springframework.format.support.DefaultFormattingConversionService;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
...@@ -67,8 +68,7 @@ public class BackgroundPreinitializer implements ApplicationListener<SpringAppli ...@@ -67,8 +68,7 @@ public class BackgroundPreinitializer implements ApplicationListener<SpringAppli
private static final boolean ENABLED; private static final boolean ENABLED;
static { static {
ENABLED = !Boolean.getBoolean(IGNORE_BACKGROUNDPREINITIALIZER_PROPERTY_NAME) ENABLED = !Boolean.getBoolean(IGNORE_BACKGROUNDPREINITIALIZER_PROPERTY_NAME) && !NativeDetector.inNativeImage()
&& System.getProperty("org.graalvm.nativeimage.imagecode") == null
&& Runtime.getRuntime().availableProcessors() > 1; && Runtime.getRuntime().availableProcessors() > 1;
} }
......
/* /*
* Copyright 2012-2020 the original author or authors. * Copyright 2012-2021 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -71,6 +71,7 @@ import org.springframework.boot.web.server.WebServer; ...@@ -71,6 +71,7 @@ import org.springframework.boot.web.server.WebServer;
import org.springframework.boot.web.servlet.ServletContextInitializer; import org.springframework.boot.web.servlet.ServletContextInitializer;
import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory; import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory;
import org.springframework.context.ResourceLoaderAware; import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.NativeDetector;
import org.springframework.core.io.ResourceLoader; import org.springframework.core.io.ResourceLoader;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.ClassUtils; import org.springframework.util.ClassUtils;
...@@ -110,8 +111,6 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto ...@@ -110,8 +111,6 @@ 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<>();
...@@ -169,7 +168,7 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto ...@@ -169,7 +168,7 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto
private static List<LifecycleListener> getDefaultLifecycleListeners() { private static List<LifecycleListener> getDefaultLifecycleListeners() {
ArrayList<LifecycleListener> lifecycleListeners = new ArrayList<>(); ArrayList<LifecycleListener> lifecycleListeners = new ArrayList<>();
if (!IN_NATIVE_IMAGE) { if (!NativeDetector.inNativeImage()) {
AprLifecycleListener aprLifecycleListener = new AprLifecycleListener(); AprLifecycleListener aprLifecycleListener = new AprLifecycleListener();
if (AprLifecycleListener.isAprAvailable()) { if (AprLifecycleListener.isAprAvailable()) {
lifecycleListeners.add(aprLifecycleListener); lifecycleListeners.add(aprLifecycleListener);
......
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