Fix handling incoming contacts sync message

This commit is contained in:
AsamK 2021-08-30 21:07:24 +02:00
parent 626406a43c
commit 0d0978011d
2 changed files with 5 additions and 6 deletions

View file

@ -88,9 +88,9 @@ public class AttachmentHelper {
SignalServiceAttachment attachment, AttachmentHandler consumer SignalServiceAttachment attachment, AttachmentHandler consumer
) throws IOException { ) throws IOException {
if (attachment.isStream()) { if (attachment.isStream()) {
try (var input = attachment.asStream().getInputStream()) { var input = attachment.asStream().getInputStream();
consumer.handle(input); // don't close input stream here, it might be reused later (e.g. with contact sync messages ...)
} consumer.handle(input);
return; return;
} }

View file

@ -215,7 +215,7 @@ public class SyncHelper {
sendHelper.sendSyncMessage(SignalServiceSyncMessage.forVerified(verifiedMessage)); sendHelper.sendSyncMessage(SignalServiceSyncMessage.forVerified(verifiedMessage));
} }
public void handleSyncDeviceContacts(final InputStream input) { public void handleSyncDeviceContacts(final InputStream input) throws IOException {
final var s = new DeviceContactsInputStream(input); final var s = new DeviceContactsInputStream(input);
DeviceContact c; DeviceContact c;
while (true) { while (true) {
@ -226,8 +226,7 @@ public class SyncHelper {
logger.warn("Sync contacts contained invalid contact, ignoring: {}", e.getMessage()); logger.warn("Sync contacts contained invalid contact, ignoring: {}", e.getMessage());
continue; continue;
} else { } else {
logger.warn("Failed to read sync contacts", e); throw e;
break;
} }
} }
if (c == null) { if (c == null) {