Skip to content

WriteDirectAsync throws System.NullReferenceException #962

@olehb007

Description

@olehb007

Hi,

Time to time I'm getting System.NullReferenceException with a following stack:

StackExchange.Redis.ServerEndPoint.WriteDirectAsync[T](Message message, ResultProcessor`1 processor, Object asyncState, PhysicalBridge bridge) in C:\proj\trouter\StackExchange.Redis\src\StackExchange.Redis\ServerEndPoint.cs: line 562
StackExchange.Redis.ServerEndPoint.SendTracer(TextWriter log) in C:\proj\trouter\StackExchange.Redis\src\StackExchange.Redis\ServerEndPoint.cs: line 591
StackExchange.Redis.ConnectionMultiplexer.d__155.MoveNext() in C:\proj\trouter\StackExchange.Redis\src\StackExchange.Redis\ConnectionMultiplexer.cs: line 1678
System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout)
StackExchange.Redis.ConnectionMultiplexer.ConnectImpl(Object configuration, TextWriter log) in C:\proj\trouter\StackExchange.Redis\src\StackExchange.Redis\ConnectionMultiplexer.cs: line 917
StackExchange.Redis.ConnectionMultiplexer.Connect(ConfigurationOptions configuration, TextWriter log) in C:\proj\trouter\StackExchange.Redis\src\StackExchange.Redis\ConnectionMultiplexer.cs: line 903

As far as I understood GetBridge can return null and thus throw on bridge.TryWrite.

        internal Task<T> WriteDirectAsync<T>(Message message, ResultProcessor<T> processor, object asyncState = null, PhysicalBridge bridge = null)
        {
            var tcs = TaskSource.Create<T>(asyncState);
            var source = ResultBox<T>.Get(tcs);
            message.SetSource(processor, source);
            if (bridge == null) bridge = GetBridge(message.Command);
    var result = bridge.TryWrite(message, isSlave);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions