UserThread must not be used before application is created.

This commit is contained in:
chimp1984 2020-10-01 23:01:49 -05:00
parent 6c28d1a097
commit f5862ec2f6
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3
2 changed files with 6 additions and 3 deletions

View File

@ -54,7 +54,6 @@ public class CommonSetup {
Version.printVersion();
maybePrintPathOfCodeSource();
Profiler.printSystemLoad();
UserThread.runPeriodically(Profiler::printSystemLoad, 10, TimeUnit.MINUTES);
setSystemProperties();
setupSigIntHandlers(gracefulShutDownHandler);
@ -62,6 +61,10 @@ public class CommonSetup {
DevEnv.setup(config);
}
public static void printSystemLoadPeriodically(int delayMin) {
UserThread.runPeriodically(Profiler::printSystemLoad, delayMin, TimeUnit.MINUTES);
}
public static void setupUncaughtExceptionHandler(UncaughtExceptionHandler uncaughtExceptionHandler) {
Thread.UncaughtExceptionHandler handler = (thread, throwable) -> {
// Might come from another thread

View File

@ -98,7 +98,6 @@ public abstract class BisqExecutable implements GracefulShutDownHandler, BisqSet
CommonSetup.setup(config, this);
CoreSetup.setup(config);
configUserThread();
addCapabilities();
// If application is JavaFX application we need to wait until it is initialized
@ -121,10 +120,11 @@ public abstract class BisqExecutable implements GracefulShutDownHandler, BisqSet
// Headless versions can call inside launchApplication the onApplicationLaunched() manually
protected void onApplicationLaunched() {
configUserThread();
CommonSetup.printSystemLoadPeriodically(10);
// As the handler method might be overwritten by subclasses and they use the application as handler
// we need to setup the handler after the application is created.
CommonSetup.setupUncaughtExceptionHandler(this);
setupGuice();
setupAvoidStandbyMode();
startApplication();