Check message type before deserializing source serviceId

This commit is contained in:
Ravi Khadiwala authored and ravi-signal committed 2026-06-11 13:16:20 -05:00
1 parent e79eb9904d
commit adb5b6a4ea
4 files changed
+92 -12

No files matched your search

@@ -58,6 +58,7 @@ class PendingAcknowledgementTracker {
void addUnacknowledgedEnvelope(final MessageProtos.Envelope envelope) {
sentMessageCounter.incrementAndGet();
final UUID messageGuid = UUIDUtil.fromByteString(envelope.getServerGuid());
// If the envelope has a source, and it is not a server delivery receipt, it will be an ACI.
final AciServiceIdentifier sourceId = envelope.hasSourceServiceId() && envelope.getType() != MessageProtos.Envelope.Type.SERVER_DELIVERY_RECEIPT
? AciServiceIdentifier.fromByteString(envelope.getSourceServiceId())
: null;
@@ -241,16 +241,12 @@ public class WebSocketConnection implements DisconnectionRequestListener {
final ServiceIdentifier destinationServiceIdentifier =
ServiceIdentifier.fromByteString(message.getDestinationServiceId());
@Nullable final AciServiceIdentifier sourceServiceIdentifier;
final boolean shouldSendDeliveryReceipt;
if (message.hasSourceServiceId()) {
sourceServiceIdentifier = AciServiceIdentifier.fromByteString(message.getSourceServiceId());
shouldSendDeliveryReceipt = message.getType() != Envelope.Type.SERVER_DELIVERY_RECEIPT;
} else {
sourceServiceIdentifier = null;
shouldSendDeliveryReceipt = false;
}
final boolean shouldSendDeliveryReceipt =
message.hasSourceServiceId() && message.getType() != Envelope.Type.SERVER_DELIVERY_RECEIPT;
// If the envelope has a source, and it is not a server delivery receipt, it will be an ACI.
@Nullable final AciServiceIdentifier sourceServiceIdentifier = shouldSendDeliveryReceipt
? AciServiceIdentifier.fromByteString(message.getSourceServiceId())
: null;
final Timer.Sample sample = Timer.start();