-
Notifications
You must be signed in to change notification settings - Fork 1k
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 StreamRefSerializer NRE bug #7333
Fix StreamRefSerializer NRE bug #7333
Conversation
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.
Self-review
@@ -37,52 +36,51 @@ public sealed class StreamRefSerializer : SerializerWithStringManifest | |||
public StreamRefSerializer(ExtendedActorSystem system) : base(system) | |||
{ | |||
_system = system; | |||
_serialization = system.Serialization; |
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 is the actual fix. system.Serialization
is null if config were added before the ActorSystem is started because all serializer plugins were instantiated before ActorSystem.Serialization
is assigned.
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 could make for a decent analyzer rule
@@ -129,7 +127,7 @@ private SequencedOnNext DeserializeSequenceOnNext(byte[] bytes) | |||
{ | |||
var onNext = Proto.Msg.SequencedOnNext.Parser.ParseFrom(bytes); | |||
var p = onNext.Payload; | |||
var payload = _serialization.Deserialize( | |||
var payload = system.Serialization.Deserialize( |
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.
Actual fix. Instead of using a field assigned Serialization
, we just retrieve it from _system.Serialization
when we need it.
@@ -169,7 +167,7 @@ private ByteString SerializeCumulativeDemand(CumulativeDemand demand) => | |||
private ByteString SerializeSequencedOnNext(SequencedOnNext onNext) | |||
{ | |||
var payload = onNext.Payload; | |||
var serializer = _serialization.FindSerializerFor(payload); | |||
var serializer = system.Serialization.FindSerializerFor(payload); |
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.
Actual fix. Instead of using a field assigned Serialization
, we just retrieve it from _system.Serialization
when we need it.
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.
lgtm
StreamRefSerializer
will throw an NRE ifActorMaterializer.DefaultConfig()
were added to actor system configuration beforeActorSystem
is started.Changes
Remove
_serialization
field from .ctor and use_system.Serialization
instead.