From 23c113948f6c856279e0c3c3fccf322015b85c87 Mon Sep 17 00:00:00 2001 From: JaniruTEC Date: Mon, 25 Jan 2021 16:20:47 +0100 Subject: [PATCH 1/3] Replaced catch with wildcard catch and added additional logger call See #1509 for further information and reasoning --- .../src/main/java/org/cryptomator/common/vaults/Vault.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main/commons/src/main/java/org/cryptomator/common/vaults/Vault.java b/main/commons/src/main/java/org/cryptomator/common/vaults/Vault.java index f3b058198..ae1f6aac6 100644 --- a/main/commons/src/main/java/org/cryptomator/common/vaults/Vault.java +++ b/main/commons/src/main/java/org/cryptomator/common/vaults/Vault.java @@ -122,6 +122,7 @@ public class Vault { } private void destroyCryptoFileSystem() { + LOG.trace("Trying to close associated CryptoFS..."); CryptoFileSystem fs = cryptoFileSystem.getAndSet(null); if (fs != null) { try { @@ -139,7 +140,7 @@ public class Vault { try { volume = volumeProvider.get(); volume.mount(fs, getEffectiveMountFlags()); - } catch (IOException | InvalidMountPointException | VolumeException e) { + } catch (Exception e) { destroyCryptoFileSystem(); throw e; } From 85c5dc8dfb646fced2ddecdb13cb7f6e7793b81d Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Mon, 25 Jan 2021 21:32:33 +0100 Subject: [PATCH 2/3] removed tmp workaround --- main/pom.xml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/main/pom.xml b/main/pom.xml index fbeed196e..bc1d82b93 100644 --- a/main/pom.xml +++ b/main/pom.xml @@ -36,7 +36,7 @@ 15 3.11 - 3.11.0 + 3.12.0 2.1.0 30.0-jre 2.29.1 @@ -175,13 +175,6 @@ java-jwt ${jwt.version} - - - com.fasterxml.jackson.core - jackson-databind - 2.10.5.1 - - From 70f6a4877cace7221817b1f44983ed6c82321a5e Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Mon, 25 Jan 2021 21:38:46 +0100 Subject: [PATCH 3/3] Make sure not to catch Errors --- .../cryptomator/ui/unlock/UnlockWorkflow.java | 24 ++++--------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/main/ui/src/main/java/org/cryptomator/ui/unlock/UnlockWorkflow.java b/main/ui/src/main/java/org/cryptomator/ui/unlock/UnlockWorkflow.java index 8cb7e0752..e91c5533c 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/unlock/UnlockWorkflow.java +++ b/main/ui/src/main/java/org/cryptomator/ui/unlock/UnlockWorkflow.java @@ -165,15 +165,7 @@ public class UnlockWorkflow extends Task { assert requirement != MountPointRequirement.PARENT_OPT_MOUNT_POINT; //Not implemented anywhere (yet) Throwable cause = impExc.getCause(); - //Cause is either null (cause the IMPE was thrown directly, e.g. because no MPC succeeded) - //or the cause was not an Exception (but some other kind of Throwable) - //Either way: Handle as generic error - if (!(cause instanceof Exception)) { - handleGenericError(impExc); - return; - } - - //From here on handle the cause, not the caught exception + // TODO: apply https://openjdk.java.net/jeps/8213076 in future JDK versions if (cause instanceof NotDirectoryException) { if (requirement == MountPointRequirement.PARENT_NO_MOUNT_POINT) { LOG.error("Unlock failed. Parent folder is missing: {}", cause.getMessage()); @@ -182,23 +174,17 @@ public class UnlockWorkflow extends Task { } showInvalidMountPointScene(); return; - } - - if (cause instanceof FileAlreadyExistsException) { + } else if (cause instanceof FileAlreadyExistsException) { LOG.error("Unlock failed. Mountpoint already exists: {}", cause.getMessage()); showInvalidMountPointScene(); return; - } - - if (cause instanceof DirectoryNotEmptyException) { + } else if (cause instanceof DirectoryNotEmptyException) { LOG.error("Unlock failed. Mountpoint not an empty directory: {}", cause.getMessage()); showInvalidMountPointScene(); return; + } else { + handleGenericError(impExc); } - - //Everything else (especially IOException) results in a generic error - //This must be done after the other exceptions because they extend IOException... - handleGenericError(cause); } private void showInvalidMountPointScene() {