Prevent NPE during migration, when profile key is null

This commit is contained in:
AsamK 2021-05-12 19:34:09 +02:00
parent 21d62c4557
commit 3fc5bec149
3 changed files with 3 additions and 2 deletions

View file

@ -547,8 +547,8 @@ public class SignalAccount implements Closeable {
final var legacyProfileStore = jsonProcessor.convertValue(profileStoreNode, LegacyProfileStore.class); final var legacyProfileStore = jsonProcessor.convertValue(profileStoreNode, LegacyProfileStore.class);
for (var profileEntry : legacyProfileStore.getProfileEntries()) { for (var profileEntry : legacyProfileStore.getProfileEntries()) {
var recipientId = recipientStore.resolveRecipient(profileEntry.getServiceAddress()); var recipientId = recipientStore.resolveRecipient(profileEntry.getServiceAddress());
recipientStore.storeProfileKey(recipientId, profileEntry.getProfileKey());
recipientStore.storeProfileKeyCredential(recipientId, profileEntry.getProfileKeyCredential()); recipientStore.storeProfileKeyCredential(recipientId, profileEntry.getProfileKeyCredential());
recipientStore.storeProfileKey(recipientId, profileEntry.getProfileKey());
final var profile = profileEntry.getProfile(); final var profile = profileEntry.getProfile();
if (profile != null) { if (profile != null) {
final var capabilities = new HashSet<Profile.Capability>(); final var capabilities = new HashSet<Profile.Capability>();

View file

@ -226,7 +226,7 @@ public class RecipientStore implements ContactsStore, ProfileStore {
public void storeProfileKey(final RecipientId recipientId, final ProfileKey profileKey) { public void storeProfileKey(final RecipientId recipientId, final ProfileKey profileKey) {
synchronized (recipients) { synchronized (recipients) {
final var recipient = recipients.get(recipientId); final var recipient = recipients.get(recipientId);
if (profileKey.equals(recipient.getProfileKey())) { if (profileKey != null && profileKey.equals(recipient.getProfileKey())) {
return; return;
} }

View file

@ -241,6 +241,7 @@ public class App {
} catch (NotRegisteredException e) { } catch (NotRegisteredException e) {
throw new UserErrorException("User " + username + " is not registered."); throw new UserErrorException("User " + username + " is not registered.");
} catch (Throwable e) { } catch (Throwable e) {
logger.debug("Loading state file failed", e);
throw new UnexpectedErrorException("Error loading state file for user " throw new UnexpectedErrorException("Error loading state file for user "
+ username + username
+ ": " + ": "