Details
Description
Because the logger is set last inside of the
ClientFailoverSocket
class, if there are issues with the
GetIpEndpoints
call, an argument exception can occur when a debug message is logged inside of
GetIps
when the ip address can't be parsed. In my case, this occurred with a DNS failure.
Stack Trace:
System.ArgumentNullException: Value cannot be null. (Parameter 'logger') at Apache.Ignite.Core.Impl.Common.IgniteArgumentCheck.NotNull(Object arg, String argName) at Apache.Ignite.Core.Log.LoggerExtensions.Log(ILogger logger, LogLevel level, Exception ex, String message) at Apache.Ignite.Core.Log.LoggerExtensions.Debug(ILogger logger, Exception ex, String message) at Apache.Ignite.Core.Impl.Client.ClientFailoverSocket.GetIps(String host, Boolean suppressExceptions) at Apache.Ignite.Core.Impl.Client.ClientFailoverSocket.<GetIpEndPoints>d__11.MoveNext() at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection) at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source) at Apache.Ignite.Core.Impl.Client.ClientFailoverSocket..ctor(IgniteClientConfiguration config, Marshaller marsh, TransactionsClient transactions) at Apache.Ignite.Core.Impl.Client.IgniteClient..ctor(IgniteClientConfiguration clientConfiguration) at Apache.Ignite.Core.Ignition.StartClient(IgniteClientConfiguration clientConfiguration)
Here's the constructor code:
Debug.Assert(config != null); Debug.Assert(marsh != null); Debug.Assert(transactions != null); _config = config; _marsh = marsh; _transactions = transactions; #pragma warning disable 618 // Type or member is obsolete if (config.Host == null && (config.Endpoints == null || config.Endpoints.Count == 0)) { throw new IgniteClientException("Invalid IgniteClientConfiguration: Host is null, " + "Endpoints is null or empty. Nowhere to connect."); } #pragma warning restore 618 _endPoints = GetIpEndPoints(config).ToList(); if (_endPoints.Count == 0) { throw new IgniteClientException("Failed to resolve all specified hosts."); } _logger = (_config.Logger ?? NoopLogger.Instance).GetLogger(GetType()); ConnectDefaultSocket(); OnFirstConnection();
Note how the _logger variable isn't set until the very end of the constructor.