Skip to content
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

Fixed System.ArgumentNullException in Interspase operation on empty stream finish. #4918

Merged
merged 1 commit into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/core/Akka.Streams.Tests/Dsl/FlowIntersperseSpec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,32 @@ public void A_Intersperse_must_surround_single_element_stream_with_start_and_end
probe.ExpectSubscription();
probe.ToStrict(TimeSpan.FromSeconds(1)).Aggregate((s, s1) => s + s1).Should().Be("[1]");
}

[Fact]
public void A_Intersperse_must_not_surround_empty_stream_with_null_start_and_stop()
{
var probe =
Source.From(new int[0])
.Select(x => x.ToString())
.Intersperse(",")
.RunWith(this.SinkProbe<string>(), Materializer);

probe.ExpectSubscription();
probe.ToStrict(TimeSpan.FromSeconds(1)).Count().Should().Be(0);
}

[Fact]
public void A_Intersperse_must_not_surround_single_element_stream_with_null_start_and_stop()
{
var probe =
Source.From(new int[]{1})
.Select(x => x.ToString())
.Intersperse(",")
.RunWith(this.SinkProbe<string>(), Materializer);

probe.ExpectSubscription();
probe.ToStrict(TimeSpan.FromSeconds(1)).Aggregate((s, s1) => s + s1).Should().Be("1");
}

[Fact]
public void A_Intersperse_must__complete_the_stage_when_the_Source_has_been_completed()
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Streams/Implementation/Fusing/Ops.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1518,7 +1518,7 @@ public override void OnPush()

public override void OnUpstreamFinish()
{
_logic.EmitMultiple(_stage.Outlet, new[] { _stage._start, _stage._end });
if (_stage.InjectStartEnd) _logic.EmitMultiple(_stage.Outlet, new[] { _stage._start, _stage._end });
_logic.CompleteStage();
}
}
Expand Down