Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronontheweb committed Dec 8, 2022
1 parent f34970d commit fbc338a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,11 @@ public void Can_serialize_StatusSuccess(object payload)
public void Can_serialize_StatusFailure(object payload)
{
var success = new Status.Failure(new ApplicationException("foo"),payload);
AssertEqual(success);
// can't use AssertEqual here since the Exception data isn't 100% identical after round-trip serialization
var deserialized = AssertAndReturn(success);
deserialized.State.Should().BeEquivalentTo(success.State);
deserialized.Cause.Message.Should().BeEquivalentTo(success.Cause.Message);
deserialized.Cause.Should().BeOfType(success.Cause.GetType());
}

[Fact]
Expand Down Expand Up @@ -392,7 +396,7 @@ private T AssertAndReturn<T>(T message)
private void AssertEqual<T>(T message)
{
var deserialized = AssertAndReturn(message);
Assert.Equal(message, deserialized);
deserialized.Should().BeEquivalentTo(message);
}
}
}
4 changes: 2 additions & 2 deletions src/core/Akka.Remote/Configuration/Remote.conf
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ akka {
"Akka.Actor.PoisonPill, Akka" = akka-misc
"Akka.Actor.Kill, Akka" = akka-misc
"Akka.Actor.PoisonPill, Akka" = akka-misc
"Akka.Actor.Status.Failure, Akka" = akka-misc
"Akka.Actor.Status.Success, Akka" = akka-misc
"Akka.Actor.Status+Failure, Akka" = akka-misc
"Akka.Actor.Status+Success, Akka" = akka-misc
#"Akka.Actor.LocalScope, Akka" = akka-misc
"Akka.Actor.RemoteScope, Akka" = akka-misc
"Akka.Routing.FromConfig, Akka" = akka-misc
Expand Down
7 changes: 2 additions & 5 deletions src/core/Akka.Remote/Serialization/MiscMessageSerializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -312,17 +312,14 @@ private byte[] StatusFailureToProto(Status.Failure failure)
{
var message = new Proto.Msg.StatusFailure();
message.Cause = _exceptionSupport.ExceptionToProto(failure.Cause);
if(failure.State != null)
message.State = _payloadSupport.PayloadToProto(failure.State);
message.State = _payloadSupport.PayloadToProto(failure.State);
return message.ToByteArray();
}

private Status.Failure StatusFailureFromProto(byte[] bytes)
{
var message = Proto.Msg.StatusFailure.Parser.ParseFrom(bytes);
object payload = string.Empty;
if(message.State != null)
payload = _payloadSupport.PayloadFrom(message.State);
var payload = _payloadSupport.PayloadFrom(message.State);
return new Status.Failure(_exceptionSupport.ExceptionFromProto(message.Cause), payload);
}

Expand Down

0 comments on commit fbc338a

Please sign in to comment.