Uploaded image for project: 'Ignite'
  1. Ignite
  2. IGNITE-14776

.NET: ClientFailoverSocket sets logger too late, resulting in null loggers downstream

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 2.10, 2.11
    • 2.12
    • clients, platforms
    • .NET: Fixed NullReferenceException in thin client due to late logger setter
    • Release Notes Required

    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.

      Attachments

        Activity

          People

            ptupitsyn Pavel Tupitsyn
            rakker91 Robert May
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 10m
                10m