Skip to content

Commit

Permalink
Merge pull request #5817 from chimp1984/fix-incorrect-app-initialisation
Browse files Browse the repository at this point in the history
Fix incorrect app initialisation
  • Loading branch information
ripcurlx authored Nov 10, 2021
2 parents 9a1dc43 + 40ad573 commit 284eaf2
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
8 changes: 5 additions & 3 deletions common/src/main/java/bisq/common/setup/CommonSetup.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,21 @@ public static void setup(Config config, GracefulShutDownHandler gracefulShutDown
Version.printVersion();
maybePrintPathOfCodeSource();
Profiler.printSystemLoad();
Profiler.printSystemLoadPeriodically(10, TimeUnit.MINUTES);

// Full DAO nodes (like seed nodes) do not use the GC triggers as it is expected they have sufficient RAM allocated.
GcUtil.setDISABLE_GC_CALLS(config.fullDaoNode);

GcUtil.autoReleaseMemory();

setSystemProperties();
setupSigIntHandlers(gracefulShutDownHandler);

DevEnv.setup(config);
}

public static void startPeriodicTasks() {
Profiler.printSystemLoadPeriodically(10, TimeUnit.MINUTES);
GcUtil.autoReleaseMemory();
}

public static void setupUncaughtExceptionHandler(UncaughtExceptionHandler uncaughtExceptionHandler) {
Thread.UncaughtExceptionHandler handler = (thread, throwable) -> {
// Might come from another thread
Expand Down
5 changes: 5 additions & 0 deletions core/src/main/java/bisq/core/app/BisqExecutable.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,13 @@ protected void addCapabilities() {
///////////////////////////////////////////////////////////////////////////////////////////

// Headless versions can call inside launchApplication the onApplicationLaunched() manually
// Desktop gets called from JavaFx thread
protected void onApplicationLaunched() {
configUserThread();

// Now we can use the user thread start periodic tasks
CommonSetup.startPeriodicTasks();

// 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);
Expand Down
4 changes: 2 additions & 2 deletions desktop/src/main/java/bisq/desktop/app/BisqAppMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ protected void configUserThread() {
protected void launchApplication() {
BisqApp.setAppLaunchedHandler(application -> {
BisqAppMain.this.application = (BisqApp) application;
// Map to user thread!
UserThread.execute(this::onApplicationLaunched);

onApplicationLaunched();
});

Application.launch(BisqApp.class);
Expand Down
2 changes: 1 addition & 1 deletion seednode/src/main/java/bisq/seednode/SeedNodeMain.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected void launchApplication() {
UserThread.execute(() -> {
try {
seedNode = new SeedNode();
UserThread.execute(this::onApplicationLaunched);
onApplicationLaunched();
} catch (Exception e) {
e.printStackTrace();
}
Expand Down

0 comments on commit 284eaf2

Please sign in to comment.