From 2687c02e31b0f8383ffeffb1f2fad3ca41020a3b Mon Sep 17 00:00:00 2001 From: Sebastian Stenzel Date: Wed, 21 Dec 2016 17:29:54 +0100 Subject: [PATCH] =?UTF-8?q?now=20passing=20unchecked=20CryptoExceptions=20?= =?UTF-8?q?up=20through=20various=20closures,=20thus=20being=20able=20to?= =?UTF-8?q?=20catch=20=E2=80=9CInvalidPassphraseException=E2=80=9D=20in=20?= =?UTF-8?q?UI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/org/cryptomator/common/LazyInitializer.java | 6 ++++-- main/pom.xml | 2 +- main/ui/src/main/java/org/cryptomator/ui/model/Vault.java | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/main/commons/src/main/java/org/cryptomator/common/LazyInitializer.java b/main/commons/src/main/java/org/cryptomator/common/LazyInitializer.java index 62f75c8e8..4d166bbb3 100644 --- a/main/commons/src/main/java/org/cryptomator/common/LazyInitializer.java +++ b/main/commons/src/main/java/org/cryptomator/common/LazyInitializer.java @@ -50,12 +50,14 @@ public final class LazyInitializer { } } - private static UnaryOperator invokeFactoryIfNull(SupplierThrowingException factory) throws InitializationException { + private static UnaryOperator invokeFactoryIfNull(SupplierThrowingException factory) throws InitializationException { return currentValue -> { if (currentValue == null) { try { return factory.get(); - } catch (Throwable e) { + } catch (RuntimeException e) { + throw e; // don't catch unchecked exceptions + } catch (Exception e) { throw new InitializationException(e); } } else { diff --git a/main/pom.xml b/main/pom.xml index 124fcaedf..a53f15157 100644 --- a/main/pom.xml +++ b/main/pom.xml @@ -28,7 +28,7 @@ 1.0.9 - 1.0.1 + 1.1.0-SNAPSHOT 0.3.0-SNAPSHOT 1.0.0 2.1 diff --git a/main/ui/src/main/java/org/cryptomator/ui/model/Vault.java b/main/ui/src/main/java/org/cryptomator/ui/model/Vault.java index dd09ba681..14ccde830 100644 --- a/main/ui/src/main/java/org/cryptomator/ui/model/Vault.java +++ b/main/ui/src/main/java/org/cryptomator/ui/model/Vault.java @@ -26,6 +26,7 @@ import org.cryptomator.common.LazyInitializer; import org.cryptomator.cryptofs.CryptoFileSystem; import org.cryptomator.cryptofs.CryptoFileSystemProperties; import org.cryptomator.cryptofs.CryptoFileSystemProvider; +import org.cryptomator.cryptolib.api.CryptoException; import org.cryptomator.cryptolib.api.InvalidPassphraseException; import org.cryptomator.frontend.webdav.WebDavServer; import org.cryptomator.frontend.webdav.mount.Mounter.CommandFailedException; @@ -76,7 +77,7 @@ public class Vault { return LazyInitializer.initializeLazily(cryptoFileSystem, () -> createCryptoFileSystem(passphrase), IOException.class); } - private CryptoFileSystem createCryptoFileSystem(CharSequence passphrase) throws IOException { + private CryptoFileSystem createCryptoFileSystem(CharSequence passphrase) throws IOException, CryptoException { CryptoFileSystemProperties fsProps = CryptoFileSystemProperties.cryptoFileSystemProperties().withPassphrase(passphrase).build(); CryptoFileSystem fs = CryptoFileSystemProvider.newFileSystem(getPath(), fsProps); closer.closeLater(fs);