Skip to content

Commit

Permalink
Fix "The application has not been initialized." after shutdown
Browse files Browse the repository at this point in the history
to "The application is already stopped."

As seen logged at the end of many junit tests.
  • Loading branch information
jukzi committed Feb 6, 2025
1 parent ad50c26 commit 27852ff
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public final class InternalPlatform {

private boolean splashEnded = false;
private volatile boolean initialized;
private volatile boolean stopped;
private static final String KEYRING = "-keyring"; //$NON-NLS-1$
private String keyringFile;

Expand Down Expand Up @@ -182,8 +183,13 @@ public void addLogListener(ILogListener listener) {

private void assertInitialized() {
//avoid the Policy.bind if assertion is true
if (!initialized)
Assert.isTrue(false, Messages.meta_appNotInit);
if (!initialized) {
if (stopped) {
Assert.isTrue(false, Messages.meta_appStopped);
} else {
Assert.isTrue(false, Messages.meta_appNotInit);
}
}
}

/**
Expand Down Expand Up @@ -677,6 +683,7 @@ public void start(BundleContext runtimeContext) {
processCommandLine(getEnvironmentInfoService().getNonFrameworkArgs());
initializeDebugFlags();
initialized = true;
stopped = false;
initializeAuthorizationHandler();
startServices();
}
Expand All @@ -691,6 +698,7 @@ public void stop(BundleContext bundleContext) {
stopServices(); // should be done after preferences shutdown
initialized = false;
closeOSGITrackers();
stopped = true;
context = null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ public class Messages extends NLS {

// metadata
public static String meta_appNotInit;
public static String meta_appStopped;
public static String meta_exceptionParsingLog;

// parsing/resolve
public static String plugin_deactivatedLoad;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ auth_notAvailable = Authorization infrastructure (org.eclipse.core.runtime.compa

### metadata
meta_appNotInit = The application has not been initialized.
meta_appStopped=The application is already stopped.
meta_exceptionParsingLog = An exception occurred while parsing the log file: {0}

### plugins
Expand Down

0 comments on commit 27852ff

Please sign in to comment.