diff --git a/app/src/main/java/io/xpipe/app/pwman/KeePassXcPasswordManager.java b/app/src/main/java/io/xpipe/app/pwman/KeePassXcPasswordManager.java index 9e41e8907..a9c2a921f 100644 --- a/app/src/main/java/io/xpipe/app/pwman/KeePassXcPasswordManager.java +++ b/app/src/main/java/io/xpipe/app/pwman/KeePassXcPasswordManager.java @@ -119,7 +119,7 @@ public class KeePassXcPasswordManager implements PasswordManager { p); } - private static synchronized KeePassXcAssociationKey associate() throws Exception { + private static KeePassXcAssociationKey associate() throws Exception { var found = findKeePassProxy(); if (found.isEmpty()) { throw ErrorEventFactory.expected(new UnsupportedOperationException("No KeePassXC installation was found")); @@ -137,14 +137,14 @@ public class KeePassXcPasswordManager implements PasswordManager { } } - public static synchronized void reset() { + public static void reset() { if (client != null) { client.disconnect(); client = null; } } - private KeePassXcProxyClient getOrCreateClient() throws Exception { + private synchronized KeePassXcProxyClient getOrCreateClient() throws Exception { if (client == null) { var found = findKeePassProxy(); if (found.isEmpty()) { @@ -269,21 +269,22 @@ public class KeePassXcPasswordManager implements PasswordManager { @Override public Result query(String key) { - synchronized (KeePassXcPasswordManager.class) { - try { - var hasScheme = Pattern.compile("^\\w+://").matcher(key).find(); - var fixedKey = hasScheme ? key : "https://" + key; - var isPrefs = this == AppPrefs.get().passwordManager().getValue(); - var client = getOrCreateClient(); - // The prefs value might be updated during the client creation - var effectiveKeys = - isPrefs ? ((KeePassXcPasswordManager) AppPrefs.get().passwordManager().getValue()).getAssociationKeys() : associationKeys; - var credentials = client.getCredentials(effectiveKeys, fixedKey); - return Result.of(credentials, null); - } catch (Exception e) { - ErrorEventFactory.fromThrowable(e).handle(); - return null; - } + try { + var hasScheme = Pattern.compile("^\\w+://").matcher(key).find(); + var fixedKey = hasScheme ? key : "https://" + key; + var isPrefs = this == AppPrefs.get().passwordManager().getValue(); + var client = getOrCreateClient(); + // The prefs value might be updated during the client creation + var effectiveKeys = isPrefs + ? ((KeePassXcPasswordManager) + AppPrefs.get().passwordManager().getValue()) + .getAssociationKeys() + : associationKeys; + var credentials = client.getCredentials(effectiveKeys, fixedKey); + return Result.of(credentials, null); + } catch (Exception e) { + ErrorEventFactory.fromThrowable(e).handle(); + return null; } }