Skip to content

NullReferenceException when disposing of ConnectionSettings #4818

@reduckted

Description

@reduckted

NEST/Elasticsearch.Net version:

  • NEST v7.8.0
  • Elasticsearch.Net v7.8.0

Elasticsearch version:
N/A

Description of the problem including expected versus actual behavior:

Disposing of a Nest.ConnectionSettings object that has not been used throws a NullReferenceException.

Steps to reproduce:
Simply run this code in a .NET Core project (didn't seem to happen with a .NET Framework project):

using (var settings = new ConnectionSettings())
{
}
System.NullReferenceException: 'Object reference not set to an instance of an object.'
   at Elasticsearch.Net.RequestDataHttpClientFactory.StopCleanupTimer()
   at Elasticsearch.Net.RequestDataHttpClientFactory.CleanupTimer_Tick()
   at Elasticsearch.Net.RequestDataHttpClientFactory.Dispose()
   at Elasticsearch.Net.HttpConnection.DisposeManagedResources()
   at Elasticsearch.Net.HttpConnection.System.IDisposable.Dispose()
   at Elasticsearch.Net.ConnectionConfiguration`1.DisposeManagedResources()
   at Elasticsearch.Net.ConnectionConfiguration`1.System.IDisposable.Dispose()

Expected behavior
An exception is not thrown.

Provide ConnectionSettings (if relevant):
N/A

Provide DebugInformation (if relevant):
N/A

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