-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix StreamRefSerializer NRE bug #7333
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
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
| 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
| 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.
| { | ||
| 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
StreamRefSerializerwill throw an NRE ifActorMaterializer.DefaultConfig()were added to actor system configuration beforeActorSystemis started.Changes
Remove
_serializationfield from .ctor and use_system.Serializationinstead.