Refactor: Rename setup to setupUncaughtExceptionHandler

rename setupErrorHandler to checkCryptoPolicySetup
move UncaughtExceptionHandler code to setupUncaughtExceptionHandler
This commit is contained in:
chimp1984 2020-09-30 21:55:50 -05:00
parent b6e97e371e
commit 7ea3676c55
No known key found for this signature in database
GPG Key ID: 9801B4EC591F90E3
6 changed files with 14 additions and 19 deletions

View File

@ -40,16 +40,7 @@ public class CommonSetup {
setSystemProperties();
}
public static void setup(UncaughtExceptionHandler uncaughtExceptionHandler) {
setupErrorHandler(uncaughtExceptionHandler);
}
protected static void setSystemProperties() {
if (Utilities.isLinux())
System.setProperty("prism.lcdtext", "false");
}
private static void setupErrorHandler(UncaughtExceptionHandler uncaughtExceptionHandler) {
public static void setupUncaughtExceptionHandler(UncaughtExceptionHandler uncaughtExceptionHandler) {
Thread.UncaughtExceptionHandler handler = (thread, throwable) -> {
// Might come from another thread
if (throwable.getCause() != null && throwable.getCause().getCause() != null &&
@ -69,7 +60,15 @@ public class CommonSetup {
};
Thread.setDefaultUncaughtExceptionHandler(handler);
Thread.currentThread().setUncaughtExceptionHandler(handler);
}
protected static void setSystemProperties() {
if (Utilities.isLinux())
System.setProperty("prism.lcdtext", "false");
}
//TODO not needed anymore
private static void checkCryptoPolicySetup(UncaughtExceptionHandler uncaughtExceptionHandler) {
try {
CryptoUtils.checkCryptoPolicySetup();
} catch (NoSuchAlgorithmException | LimitedKeyStrengthException e) {

View File

@ -22,8 +22,6 @@ import bisq.common.app.AppModule;
import bisq.common.app.Version;
import bisq.common.setup.CommonSetup;
import joptsimple.OptionSet;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.util.concurrent.Executors;
@ -72,7 +70,7 @@ public class BisqHeadlessAppMain extends BisqExecutable {
@Override
protected void launchApplication() {
headlessApp = new BisqHeadlessApp();
CommonSetup.setup(BisqHeadlessAppMain.this.headlessApp);
CommonSetup.setupUncaughtExceptionHandler(BisqHeadlessAppMain.this.headlessApp);
UserThread.execute(this::onApplicationLaunched);
}

View File

@ -62,7 +62,7 @@ public class BisqDaemonMain extends BisqHeadlessAppMain implements BisqSetup.Bis
@Override
protected void launchApplication() {
headlessApp = new BisqDaemon();
CommonSetup.setup(BisqDaemonMain.this.headlessApp);
CommonSetup.setupUncaughtExceptionHandler(BisqDaemonMain.this.headlessApp);
UserThread.execute(this::onApplicationLaunched);
}

View File

@ -78,7 +78,7 @@ public class BisqAppMain extends BisqExecutable {
BisqAppMain.this.application = (BisqApp) application;
// Necessary to do the setup at this point to prevent Bouncy Castle errors
CommonSetup.setup(BisqAppMain.this.application);
CommonSetup.setupUncaughtExceptionHandler(BisqAppMain.this.application);
// Map to user thread!
UserThread.execute(this::onApplicationLaunched);
});

View File

@ -50,7 +50,7 @@ public class SeedNodeMain extends ExecutableForAppWithP2p {
super.doExecute();
checkMemory(config, this);
CommonSetup.setup(this);
CommonSetup.setupUncaughtExceptionHandler(this);
keepRunning();
}

View File

@ -24,8 +24,6 @@ import bisq.common.UserThread;
import bisq.common.app.AppModule;
import bisq.common.setup.CommonSetup;
import joptsimple.OptionSet;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@ -47,7 +45,7 @@ public class StatisticsMain extends ExecutableForAppWithP2p {
super.doExecute();
checkMemory(config, this);
CommonSetup.setup(this);
CommonSetup.setupUncaughtExceptionHandler(this);
keepRunning();
}