Skip to content

Commit 6552f78

Browse files
committed
Workarounds for uncatched exceptions
1 parent f430081 commit 6552f78

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

src/main/java/org/cryptomator/linux/keychain/KDEWalletKeychainAccess.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.freedesktop.dbus.connections.impl.DBusConnectionBuilder;
1010
import org.freedesktop.dbus.exceptions.DBusConnectionException;
1111
import org.freedesktop.dbus.exceptions.DBusException;
12+
import org.freedesktop.dbus.exceptions.DBusExecutionException;
1213
import org.kde.KWallet;
1314
import org.kde.Static;
1415
import org.purejava.KDEWallet;
@@ -28,7 +29,13 @@ public class KDEWalletKeychainAccess implements KeychainAccessProvider {
2829
private final Optional<ConnectedWallet> wallet;
2930

3031
public KDEWalletKeychainAccess() {
31-
this.wallet = ConnectedWallet.connect();
32+
Optional<ConnectedWallet> tmp;
33+
try { //TODO: remove try-catch once KDEWallet lib is fixed
34+
tmp = ConnectedWallet.connect();
35+
} catch (DBusExecutionException e) {
36+
tmp = Optional.empty();
37+
}
38+
wallet = tmp;
3239
}
3340

3441
@Override

src/main/java/org/cryptomator/linux/keychain/SecretServiceKeychainAccess.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import org.cryptomator.integrations.common.Priority;
55
import org.cryptomator.integrations.keychain.KeychainAccessException;
66
import org.cryptomator.integrations.keychain.KeychainAccessProvider;
7+
import org.freedesktop.dbus.exceptions.DBusConnectionException;
8+
import org.freedesktop.dbus.exceptions.DBusExecutionException;
79
import org.freedesktop.secret.simple.SimpleCollection;
810

911
import java.io.IOException;
@@ -23,7 +25,16 @@ public String displayName() {
2325

2426
@Override
2527
public boolean isSupported() {
26-
return SimpleCollection.isAvailable();
28+
try {
29+
return SimpleCollection.isAvailable();
30+
} catch (ExceptionInInitializerError e) {
31+
//TODO: remove try-catch once secret-service lib is fixed
32+
if(e.getException() instanceof DBusExecutionException) {
33+
return false;
34+
} else {
35+
throw e;
36+
}
37+
}
2738
}
2839

2940
@Override

0 commit comments

Comments
 (0)