Merge pull request #33240 from sdeleuze
* gh-33240: Refine BackgroundPreinitializer code reachability Closes gh-33240
This commit is contained in:
commit
2f34346acf
|
|
@ -64,12 +64,8 @@ public class BackgroundPreinitializer implements ApplicationListener<SpringAppli
|
||||||
|
|
||||||
private static final CountDownLatch preinitializationComplete = new CountDownLatch(1);
|
private static final CountDownLatch preinitializationComplete = new CountDownLatch(1);
|
||||||
|
|
||||||
private static final boolean ENABLED;
|
private static final boolean ENABLED = !Boolean.getBoolean(IGNORE_BACKGROUNDPREINITIALIZER_PROPERTY_NAME)
|
||||||
|
&& Runtime.getRuntime().availableProcessors() > 1;
|
||||||
static {
|
|
||||||
ENABLED = !Boolean.getBoolean(IGNORE_BACKGROUNDPREINITIALIZER_PROPERTY_NAME) && !NativeDetector.inNativeImage()
|
|
||||||
&& Runtime.getRuntime().availableProcessors() > 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getOrder() {
|
public int getOrder() {
|
||||||
|
|
@ -78,7 +74,7 @@ public class BackgroundPreinitializer implements ApplicationListener<SpringAppli
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onApplicationEvent(SpringApplicationEvent event) {
|
public void onApplicationEvent(SpringApplicationEvent event) {
|
||||||
if (!ENABLED) {
|
if (!ENABLED || NativeDetector.inNativeImage()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event instanceof ApplicationEnvironmentPreparedEvent
|
if (event instanceof ApplicationEnvironmentPreparedEvent
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue