diff --git a/src/com/fsck/k9/Account.java b/src/com/fsck/k9/Account.java index 4f16dfeba..c2939a4ee 100644 --- a/src/com/fsck/k9/Account.java +++ b/src/com/fsck/k9/Account.java @@ -1900,6 +1900,10 @@ public class Account implements BaseAccount { } String oldHost = uri.getHost(); int oldPort = uri.getPort(); + if (oldPort == -1) { + // This occurs when a new account is created + return; + } if (!newHost.equals(oldHost) || newPort != oldPort) { LocalKeyStore localKeyStore = LocalKeyStore.getInstance(context); localKeyStore.deleteCertificate(oldHost, oldPort); diff --git a/src/com/fsck/k9/security/LocalKeyStore.java b/src/com/fsck/k9/security/LocalKeyStore.java index c7321e891..8e88f2593 100644 --- a/src/com/fsck/k9/security/LocalKeyStore.java +++ b/src/com/fsck/k9/security/LocalKeyStore.java @@ -24,7 +24,7 @@ public class LocalKeyStore { private static LocalKeyStore sInstance; - public static LocalKeyStore getInstance(Context context) { + public synchronized static LocalKeyStore getInstance(Context context) { if (sInstance == null) { sInstance = new LocalKeyStore(context); }