bchavez / RethinkDb.Driver

:headphones: A NoSQL C#/.NET RethinkDB database driver with 100% ReQL API coverage.

Home Page:http://rethinkdb.com/api/java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NullReferenceException when executing a query after a failed reconnect.

gjhommersom opened this issue · comments

Steps to reproduce:

  1. Connect with RethinkDb.
  2. Stop the RethinkDb service.
  3. Execute a query.
  4. Do a reconnect.
  5. Execute a query.

Expected result:
A ReqlError indication that there is no active connection.

Actual result:
A NullReferenceException.

Other information:
The exception occurs because the pump is not set due to reconnect failing. Checking if the connection is open would fix this problem.

Affected code:

public virtual Task<Response> SendQuery(long token, string json, bool awaitResponse, CancellationToken cancelToken)
{
    cancelToken.ThrowIfCancellationRequested();
    if( pump.IsCancellationRequested )
    {
        throw new ReqlDriverError($"Threads may not {nameof(SendQuery)} because the connection is shutting down.");
    }
    
    ...
}