]> nmode's Git Repositories - signal-cli/commitdiff
Prevent NPE during migration, when profile key is null
authorAsamK <asamk@gmx.de>
Wed, 12 May 2021 17:34:09 +0000 (19:34 +0200)
committerAsamK <asamk@gmx.de>
Wed, 12 May 2021 17:34:09 +0000 (19:34 +0200)
lib/src/main/java/org/asamk/signal/manager/storage/SignalAccount.java
lib/src/main/java/org/asamk/signal/manager/storage/recipients/RecipientStore.java
src/main/java/org/asamk/signal/App.java

index 475f26e8f6e478df3095d2358eb3f291dbb825fe..f5ac995c601dae5cb1471e4d963dd3799777a9c9 100644 (file)
@@ -547,8 +547,8 @@ public class SignalAccount implements Closeable {
             final var legacyProfileStore = jsonProcessor.convertValue(profileStoreNode, LegacyProfileStore.class);
             for (var profileEntry : legacyProfileStore.getProfileEntries()) {
                 var recipientId = recipientStore.resolveRecipient(profileEntry.getServiceAddress());
-                recipientStore.storeProfileKey(recipientId, profileEntry.getProfileKey());
                 recipientStore.storeProfileKeyCredential(recipientId, profileEntry.getProfileKeyCredential());
+                recipientStore.storeProfileKey(recipientId, profileEntry.getProfileKey());
                 final var profile = profileEntry.getProfile();
                 if (profile != null) {
                     final var capabilities = new HashSet<Profile.Capability>();
index fb7394b5b53a1ba998e0f2b0a361464976ed6318..c8a1134005792155b7f85f00cd6fd43bc046e55f 100644 (file)
@@ -226,7 +226,7 @@ public class RecipientStore implements ContactsStore, ProfileStore {
     public void storeProfileKey(final RecipientId recipientId, final ProfileKey profileKey) {
         synchronized (recipients) {
             final var recipient = recipients.get(recipientId);
-            if (profileKey.equals(recipient.getProfileKey())) {
+            if (profileKey != null && profileKey.equals(recipient.getProfileKey())) {
                 return;
             }
 
index af3fea4c5e92c0dfbd5a83687f684473ea0bd59f..5c19a4034b8a0ae9be1c6b1b4a43b5d440ab675a 100644 (file)
@@ -241,6 +241,7 @@ public class App {
         } catch (NotRegisteredException e) {
             throw new UserErrorException("User " + username + " is not registered.");
         } catch (Throwable e) {
+            logger.debug("Loading state file failed", e);
             throw new UnexpectedErrorException("Error loading state file for user "
                     + username
                     + ": "