From af3fc4e2dc1a4547c7cf8cc27385ab8c6d1d55db Mon Sep 17 00:00:00 2001 From: mikera Date: Wed, 28 Aug 2024 08:35:30 +0100 Subject: [PATCH] Remove more questionable catches of Throwable --- .../src/test/java/convex/cli/key/KeyExportTest.java | 8 +++----- .../src/main/java/convex/gui/server/StressPanel.java | 2 +- convex-java/src/test/java/example/trader/Trader.java | 2 +- .../src/main/java/convex/observer/AObserverQueue.java | 3 ++- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/convex-cli/src/test/java/convex/cli/key/KeyExportTest.java b/convex-cli/src/test/java/convex/cli/key/KeyExportTest.java index 1696a1482..416783022 100644 --- a/convex-cli/src/test/java/convex/cli/key/KeyExportTest.java +++ b/convex-cli/src/test/java/convex/cli/key/KeyExportTest.java @@ -17,7 +17,6 @@ import convex.core.crypto.PFXTools; import convex.core.data.AccountKey; import convex.core.util.FileUtils; -import convex.core.util.Utils; public class KeyExportTest { private static final char[] KEYSTORE_PASSWORD = "testPassword".toCharArray(); @@ -31,10 +30,9 @@ public class KeyExportTest { TEMP_FILE=Helpers.createTempFile("tempKeystore", ".pfx"); PFXTools.createStore(TEMP_FILE, KEYSTORE_PASSWORD); KEYSTORE_FILENAME = TEMP_FILE.getCanonicalPath(); - } catch (Throwable t) { - throw Utils.sneakyThrow(t); - } - + } catch (Exception t) { + throw new Error(t); + } } @Test diff --git a/convex-gui/src/main/java/convex/gui/server/StressPanel.java b/convex-gui/src/main/java/convex/gui/server/StressPanel.java index 6e94dc6e0..172a5801a 100644 --- a/convex-gui/src/main/java/convex/gui/server/StressPanel.java +++ b/convex-gui/src/main/java/convex/gui/server/StressPanel.java @@ -214,7 +214,7 @@ protected String doInBackground() { running=repeatCheckBox.isSelected(); if (running) Thread.sleep(((Integer)(repeatTimeSpinner.getValue()))*1000); }; - } catch (Throwable e) { + } catch (Exception e) { log.warn("Stress test worker terminated unexpectedly",e); resultArea.setText("Test Error: "+e); } finally { diff --git a/convex-java/src/test/java/example/trader/Trader.java b/convex-java/src/test/java/example/trader/Trader.java index 6474dc7f4..5c75b717c 100644 --- a/convex-java/src/test/java/example/trader/Trader.java +++ b/convex-java/src/test/java/example/trader/Trader.java @@ -11,7 +11,7 @@ public static void main(String [] args) { InputStream is=classLoader.getResourceAsStream("example/trader/APIKEY"); String text = new String(is.readAllBytes()); System.out.println("Using API key: "+text); - } catch (Throwable e) { + } catch (Exception e) { e.printStackTrace(); throw new Error(e); diff --git a/convex-observer/src/main/java/convex/observer/AObserverQueue.java b/convex-observer/src/main/java/convex/observer/AObserverQueue.java index 0eac21b16..c1ebb53ed 100644 --- a/convex-observer/src/main/java/convex/observer/AObserverQueue.java +++ b/convex-observer/src/main/java/convex/observer/AObserverQueue.java @@ -57,9 +57,10 @@ public void run() { try { loop(); } catch (InterruptedException e) { + Thread.currentThread().interrupt(); // maintain interrupt status log.debug("Component thread interrupted: {}",thread); break; - } catch (Throwable e) { + } catch (Exception e) { log.warn("Unexpected exception in "+this.getClass().getSimpleName(),e); // Stop observer ?? // break;