Skip to content

Commit 9628df8

Browse files
committed
Merge branch '2.4.x'
Closes gh-25304
2 parents 488c313 + 55e3ca6 commit 9628df8

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/BackgroundPreinitializer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,6 +29,7 @@
2929
import org.springframework.boot.context.event.SpringApplicationEvent;
3030
import org.springframework.boot.context.logging.LoggingApplicationListener;
3131
import org.springframework.context.ApplicationListener;
32+
import org.springframework.core.NativeDetector;
3233
import org.springframework.core.annotation.Order;
3334
import org.springframework.format.support.DefaultFormattingConversionService;
3435
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
@@ -67,8 +68,7 @@ public class BackgroundPreinitializer implements ApplicationListener<SpringAppli
6768
private static final boolean ENABLED;
6869

6970
static {
70-
ENABLED = !Boolean.getBoolean(IGNORE_BACKGROUNDPREINITIALIZER_PROPERTY_NAME)
71-
&& System.getProperty("org.graalvm.nativeimage.imagecode") == null
71+
ENABLED = !Boolean.getBoolean(IGNORE_BACKGROUNDPREINITIALIZER_PROPERTY_NAME) && !NativeDetector.inNativeImage()
7272
&& Runtime.getRuntime().availableProcessors() > 1;
7373
}
7474

spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactory.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2020 the original author or authors.
2+
* Copyright 2012-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -71,6 +71,7 @@
7171
import org.springframework.boot.web.servlet.ServletContextInitializer;
7272
import org.springframework.boot.web.servlet.server.AbstractServletWebServerFactory;
7373
import org.springframework.context.ResourceLoaderAware;
74+
import org.springframework.core.NativeDetector;
7475
import org.springframework.core.io.ResourceLoader;
7576
import org.springframework.util.Assert;
7677
import org.springframework.util.ClassUtils;
@@ -110,8 +111,6 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto
110111
*/
111112
public static final String DEFAULT_PROTOCOL = "org.apache.coyote.http11.Http11NioProtocol";
112113

113-
private static final boolean IN_NATIVE_IMAGE = System.getProperty("org.graalvm.nativeimage.imagecode") != null;
114-
115114
private File baseDirectory;
116115

117116
private List<Valve> engineValves = new ArrayList<>();
@@ -169,7 +168,7 @@ public TomcatServletWebServerFactory(String contextPath, int port) {
169168

170169
private static List<LifecycleListener> getDefaultLifecycleListeners() {
171170
ArrayList<LifecycleListener> lifecycleListeners = new ArrayList<>();
172-
if (!IN_NATIVE_IMAGE) {
171+
if (!NativeDetector.inNativeImage()) {
173172
AprLifecycleListener aprLifecycleListener = new AprLifecycleListener();
174173
if (AprLifecycleListener.isAprAvailable()) {
175174
lifecycleListeners.add(aprLifecycleListener);

0 commit comments

Comments
 (0)