From 60ffdbab35b6c0bb388aa59731506a5367583499 Mon Sep 17 00:00:00 2001 From: chimp1984 Date: Sun, 27 Dec 2020 23:36:38 -0500 Subject: [PATCH 1/3] Show stack trace in error popup if view gets an exception at initialize. --- .../desktop/common/fxml/FxmlViewLoader.java | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/desktop/src/main/java/bisq/desktop/common/fxml/FxmlViewLoader.java b/desktop/src/main/java/bisq/desktop/common/fxml/FxmlViewLoader.java index 9e88dfb99e0..95135a0561b 100644 --- a/desktop/src/main/java/bisq/desktop/common/fxml/FxmlViewLoader.java +++ b/desktop/src/main/java/bisq/desktop/common/fxml/FxmlViewLoader.java @@ -23,9 +23,13 @@ import bisq.desktop.common.view.ViewFactory; import bisq.desktop.common.view.ViewLoader; +import bisq.common.util.Utilities; + import javax.inject.Inject; import javax.inject.Singleton; +import com.google.common.base.Joiner; + import javafx.fxml.FXMLLoader; import java.net.URL; @@ -36,8 +40,11 @@ import java.lang.annotation.Annotation; +import lombok.extern.slf4j.Slf4j; + import static com.google.common.base.Preconditions.checkNotNull; +@Slf4j @Singleton public class FxmlViewLoader implements ViewLoader { @@ -107,7 +114,17 @@ private View loadFromFxml(URL fxmlUrl) { "does not implement [%s] as expected.", controller.getClass(), fxmlUrl, View.class); return (View) controller; } catch (IOException ex) { - throw new ViewfxException(ex, "Failed to load view from FXML file at [%s]", fxmlUrl); + Throwable cause = ex.getCause(); + if (cause != null) { + cause.printStackTrace(); + log.error(cause.toString()); + // We want to show stackTrace in error popup + String stackTrace = Utilities.toTruncatedString(Joiner.on("\n").join(cause.getStackTrace()), 800, false); + throw new ViewfxException(cause, "%s at loading view class\nStack trace:\n%s", + cause.getClass().getSimpleName(), stackTrace); + } else { + throw new ViewfxException(ex, "Failed to load view from FXML file at [%s]", fxmlUrl); + } } } @@ -122,8 +139,7 @@ private static Object getDefaultValue(Class annotationType } try { return annotationType.getDeclaredMethod(attributeName).getDefaultValue(); - } - catch (Exception ex) { + } catch (Exception ex) { return null; } } From 8350f22c0f0a7fa5ae57e613621c111df4e48d7d Mon Sep 17 00:00:00 2001 From: chimp1984 Date: Sun, 27 Dec 2020 23:37:08 -0500 Subject: [PATCH 2/3] Set correct type of cache map --- .../main/java/bisq/desktop/common/view/CachingViewLoader.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/desktop/src/main/java/bisq/desktop/common/view/CachingViewLoader.java b/desktop/src/main/java/bisq/desktop/common/view/CachingViewLoader.java index cab1bc9d70b..9f92d779191 100644 --- a/desktop/src/main/java/bisq/desktop/common/view/CachingViewLoader.java +++ b/desktop/src/main/java/bisq/desktop/common/view/CachingViewLoader.java @@ -21,11 +21,12 @@ import javax.inject.Singleton; import java.util.HashMap; +import java.util.Map; @Singleton public class CachingViewLoader implements ViewLoader { - private final HashMap cache = new HashMap<>(); + private final Map, View> cache = new HashMap<>(); private final ViewLoader viewLoader; @Inject From 6fe19db233ae65ba1177ffb9af9df9f22843a9ea Mon Sep 17 00:00:00 2001 From: chimp1984 Date: Sun, 27 Dec 2020 23:38:17 -0500 Subject: [PATCH 3/3] Only check for downGrade if we are on mainnet Its a bit annoying for dev testing when switching between release and master... --- core/src/main/java/bisq/core/app/BisqSetup.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/bisq/core/app/BisqSetup.java b/core/src/main/java/bisq/core/app/BisqSetup.java index 9b2d2300303..769cdcf4486 100644 --- a/core/src/main/java/bisq/core/app/BisqSetup.java +++ b/core/src/main/java/bisq/core/app/BisqSetup.java @@ -51,6 +51,7 @@ import bisq.common.app.DevEnv; import bisq.common.app.Log; import bisq.common.app.Version; +import bisq.common.config.BaseCurrencyNetwork; import bisq.common.config.Config; import bisq.common.util.InvalidVersionException; import bisq.common.util.Utilities; @@ -273,7 +274,8 @@ public void addBisqSetupListener(BisqSetupListener listener) { public void start() { // If user tried to downgrade we require a shutdown - if (hasDowngraded(downGradePreventionHandler)) { + if (Config.baseCurrencyNetwork() == BaseCurrencyNetwork.BTC_MAINNET && + hasDowngraded(downGradePreventionHandler)) { return; }