Skip to content

Commit

Permalink
Merge pull request #33240 from sdeleuze
Browse files Browse the repository at this point in the history
* gh-33240:
  Refine BackgroundPreinitializer code reachability

Closes gh-33240
  • Loading branch information
wilkinsona committed Nov 18, 2022
2 parents 517ec65 + e7f91ba commit 2f34346
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,8 @@ public class BackgroundPreinitializer implements ApplicationListener<SpringAppli

private static final CountDownLatch preinitializationComplete = new CountDownLatch(1);

private static final boolean ENABLED;

static {
ENABLED = !Boolean.getBoolean(IGNORE_BACKGROUNDPREINITIALIZER_PROPERTY_NAME) && !NativeDetector.inNativeImage()
&& Runtime.getRuntime().availableProcessors() > 1;
}
private static final boolean ENABLED = !Boolean.getBoolean(IGNORE_BACKGROUNDPREINITIALIZER_PROPERTY_NAME)
&& Runtime.getRuntime().availableProcessors() > 1;

@Override
public int getOrder() {
Expand All @@ -78,7 +74,7 @@ public int getOrder() {

@Override
public void onApplicationEvent(SpringApplicationEvent event) {
if (!ENABLED) {
if (!ENABLED || NativeDetector.inNativeImage()) {
return;
}
if (event instanceof ApplicationEnvironmentPreparedEvent
Expand Down

0 comments on commit 2f34346

Please sign in to comment.