Skip to content

Null Exception at Akka.Streams.Stage.GraphStageLogic.ConcurrentAsyncCallback with Generic channel types #7794

@carlcamilleri

Description

@carlcamilleri

Version Information
1.5.46
Akka.DependencyInjection
Akka.Hosting
Akka.Streams

Describe the bug
The following error is encountered:

System.NullReferenceException: Object reference not set to an instance of an object.
at Akka.Streams.Stage.GraphStageLogic.ConcurrentAsyncCallback`1.<>c__DisplayClass3_0.<.ctor>b__0(Object obj)
at Akka.Streams.Implementation.Fusing.GraphInterpreter.RunAsyncInput(GraphStageLogic logic, Object evt, TaskCompletionSource`1 promise, Action`1 handler)

To Reproduce


using var system = ActorSystem.Create("ChannelExample");
using var actorSystemMaterializer = system.Materializer();
var channel = Channel.CreateBounded<Message<string, string>>(new BoundedChannelOptions(capacity: 100)
{
 FullMode = BoundedChannelFullMode.Wait,
 SingleReader = true,
 SingleWriter = true,
 AllowSynchronousContinuations = false
});


var streamRes = ChannelSource.FromReader(channel.Reader)
   .Select(e => e)
   .RunWith(Sink.Ignore<Message<string, string>>(), actorSystemMaterializer);

_ = Task.Run(async () =>
{
 await Task.Delay(100);
 channel.Writer.Complete();
});

await streamRes;

Message is defined as:

public class Message<TKey, TValue>
{
    public TKey Key { get; set; }
    public TValue Value { get; set; }
}

The problem is not reproduced when sending on Channel<string> i.e., in this example:

using var system = ActorSystem.Create("ChannelExample");
using var actorSystemMaterializer = system.Materializer();
var channel = Channel.CreateBounded<string>(new BoundedChannelOptions(capacity: 100)
{
 FullMode = BoundedChannelFullMode.Wait,
 SingleReader = true,
 SingleWriter = true,
 AllowSynchronousContinuations = false
});


var streamRes = ChannelSource.FromReader(channel.Reader)
   .Select(e => e)
   .RunWith(Sink.Ignore<Message<string, string>>(), actorSystemMaterializer);

_ = Task.Run(async () =>
{
 await Task.Delay(100);
 channel.Writer.Complete();
});

await streamRes;

Expected behavior
No error should be encountered when using object types in channels

Actual behavior
Error encountered

Environment
Linux, Dotnet 9

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions