-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix StreamRefSerializer NRE bug (#7333)
* Fix StreamRefSerializer NRE bug * Update API Approval list
- Loading branch information
Showing
4 changed files
with
77 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/core/Akka.Streams.Tests/Serialization/StreamRefSerializer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// ----------------------------------------------------------------------- | ||
// <copyright file="StreamRefSerializer.cs" company="Akka.NET Project"> | ||
// Copyright (C) 2009-2024 Lightbend Inc. <http://www.lightbend.com> | ||
// Copyright (C) 2013-2024 .NET Foundation <https://github.com/akkadotnet/akka.net> | ||
// </copyright> | ||
// ----------------------------------------------------------------------- | ||
|
||
using System; | ||
using Akka.Serialization; | ||
using Akka.Streams.Implementation.StreamRef; | ||
using FluentAssertions; | ||
using Xunit; | ||
using Xunit.Abstractions; | ||
using static FluentAssertions.FluentActions; | ||
|
||
namespace Akka.Streams.Tests.Serialization; | ||
|
||
public class StreamRefSerializer: Akka.TestKit.Xunit2.TestKit | ||
{ | ||
public StreamRefSerializer(ITestOutputHelper output) | ||
: base(ActorMaterializer.DefaultConfig(), nameof(StreamRefSerializer), output) | ||
{ | ||
} | ||
|
||
[Fact(DisplayName = "StreamRefSerializer should not throw NRE when configuration were set before ActorSystem started")] | ||
public void StreamsConfigBugTest() | ||
{ | ||
var message = new SequencedOnNext(10, "test"); | ||
var serializer = (SerializerWithStringManifest)Sys.Serialization.FindSerializerFor(message); | ||
var manifest = serializer.Manifest(message); | ||
|
||
byte[] bytes = null; | ||
Invoking(() => | ||
{ | ||
bytes = serializer.ToBinary(message); // This throws an NRE in the bug | ||
}).Should().NotThrow<NullReferenceException>(); | ||
|
||
var deserialized = (SequencedOnNext) serializer.FromBinary(bytes, manifest); | ||
deserialized.SeqNr.Should().Be(message.SeqNr); | ||
deserialized.Payload.Should().Be(message.Payload); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters