New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Akka.Remote serialization exception bubbling and messages #5072
Changes from 6 commits
264855c
290e9d6
ad373c8
38eb0e7
2f46b34
97eba62
ae3c2f8
e49799a
faef7d1
9770008
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Runtime.Serialization; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Akka.Actor; | ||
using Akka.Configuration; | ||
using Akka.Remote.Configuration; | ||
using Akka.Serialization; | ||
using Akka.TestKit; | ||
using FluentAssertions; | ||
using Google.Protobuf; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
|
||
namespace Akka.Remote.Tests.Serialization | ||
{ | ||
public class BugFix5062Spec: AkkaSpec | ||
{ | ||
private static Config DDataConfig => ConfigurationFactory.ParseString($@" | ||
akka.actor {{ | ||
serializers {{ | ||
dummyWithManifest = ""{typeof(DummySerializerWithStringManifest).AssemblyQualifiedName}"" | ||
}} | ||
serialization-bindings {{ | ||
""{typeof(SomeMessage).AssemblyQualifiedName}"" = dummyWithManifest | ||
}} | ||
serialization-identifiers {{ | ||
""{typeof(DummySerializerWithStringManifest).AssemblyQualifiedName}"" = 13 | ||
}} | ||
}}") | ||
.WithFallback(RemoteConfigFactory.Default()); | ||
|
||
public BugFix5062Spec(ITestOutputHelper output) : base(output, DDataConfig) | ||
{ } | ||
|
||
[Fact] | ||
public void Failed_serialization_should_give_proper_exception_message() | ||
{ | ||
var message = new ActorSelectionMessage( | ||
new SomeMessage(), | ||
new SelectionPathElement[] { new SelectChildName("dummy") }, | ||
true); | ||
|
||
var node1 = new Address("akka.tcp", "Sys", "localhost", 2551); | ||
var serialized = MessageSerializer.Serialize((ExtendedActorSystem)Sys, node1, message); | ||
|
||
var o = new object(); | ||
var ex = o.Invoking(s => MessageSerializer.Deserialize((ExtendedActorSystem)Sys, serialized)).Should() | ||
.Throw<SerializationException>() | ||
.WithMessage("Failed to deserialize object with serialization id [6] (manifest []).") | ||
//.WithInnerExceptionExactly<SerializationException>() | ||
//.WithMessage("Failed to deserialize object with serialization id [11] (manifest [E]).") | ||
.WithInnerExceptionExactly<SerializationException>() | ||
.WithMessage("Failed to deserialize object with serialization id [13] (manifest [SM])."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your use case and reproduction here is wrong - need to have a scenario where The goal of this bug is to unpack the inner exception and throw that - so the user gets a clear error message: that the payload carried by an |
||
} | ||
|
||
public class SomeMessage | ||
{ | ||
} | ||
|
||
public class DummySerializerWithStringManifest : SerializerWithStringManifest | ||
{ | ||
public DummySerializerWithStringManifest(ExtendedActorSystem system) : base(system) | ||
{ | ||
} | ||
|
||
public override byte[] ToBinary(object obj) | ||
{ | ||
return Array.Empty<byte>(); | ||
} | ||
|
||
public override object FromBinary(byte[] bytes, string manifest) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public override string Manifest(object o) | ||
{ | ||
if (o is SomeMessage) | ||
return "SM"; | ||
throw new Exception("Unknown object type"); | ||
} | ||
} | ||
|
||
|
||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This literally reproduces the error we want to get rid of in #5062