Skip to content

Commit 2dc1c57

Browse files
Akka.Remote: harden EndpointWriter against serialization failures (#7923) (#7925)
close #7922
1 parent 98c25d1 commit 2dc1c57

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

src/core/Akka.Remote/Endpoint.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1481,8 +1481,17 @@ private bool WriteSend(EndpointManager.Send send)
14811481
send.Recipient, send.Recipient.Path, send.SenderOption ?? _system.DeadLetters);
14821482
}
14831483

1484-
var pdu = _codec.ConstructMessage(send.Recipient.LocalAddressToUse, send.Recipient,
1485-
SerializeMessage(send.Message), send.SenderOption, send.Seq, _lastAck);
1484+
ByteString pdu;
1485+
try
1486+
{
1487+
pdu = _codec.ConstructMessage(send.Recipient.LocalAddressToUse, send.Recipient,
1488+
SerializeMessage(send.Message), send.SenderOption, send.Seq, _lastAck);
1489+
}
1490+
catch (Exception e) when (e is not SerializationException)
1491+
{
1492+
// resolves https://github.com/akkadotnet/akka.net/issues/7922
1493+
throw new SerializationException("Serializer failed with exception", e);
1494+
}
14861495

14871496
_remoteMetrics.LogPayloadBytes(send.Message, pdu.Length);
14881497

@@ -1518,14 +1527,6 @@ private bool WriteSend(EndpointManager.Send send)
15181527
LogPossiblyWrappedMessageType(send.Message));
15191528
return true;
15201529
}
1521-
catch (ArgumentException ex)
1522-
{
1523-
_log.Error(
1524-
ex,
1525-
"Serializer threw ArgumentException for message type [{0}]. Transient association error (association remains live)",
1526-
LogPossiblyWrappedMessageType(send.Message));
1527-
return true;
1528-
}
15291530
catch (EndpointException ex)
15301531
{
15311532
PublishAndThrow(ex, LogLevel.ErrorLevel);

0 commit comments

Comments
 (0)