IGNITE-7399 .NET: Thin client: Fix NPE in Dispose
authorPavel Tupitsyn <ptupitsyn@apache.org>
Mon, 15 Jan 2018 11:00:32 +0000 (14:00 +0300)
committerPavel Tupitsyn <ptupitsyn@apache.org>
Mon, 15 Jan 2018 11:00:32 +0000 (14:00 +0300)
modules/platforms/dotnet/Apache.Ignite.Core.Tests/Client/ClientConnectionTest.cs
modules/platforms/dotnet/Apache.Ignite.Core/Impl/Client/ClientSocket.cs

index 1da60b1..417e60a 100644 (file)
@@ -304,6 +304,21 @@ namespace Apache.Ignite.Core.Tests.Client
         }
 
         /// <summary>
+        /// Tests the protocol mismatch behavior: attempt to connect to an HTTP endpoint.
+        /// </summary>
+        [Test]
+        public void TestProtocolMismatch()
+        {
+            using (Ignition.Start(TestUtils.GetTestConfiguration()))
+            {
+                // Connect to Ignite REST endpoint.
+                var cfg = new IgniteClientConfiguration {Host = "127.0.0.1", Port = 11211 };
+                var ex = Assert.Throws<SocketException>(() => Ignition.StartClient(cfg));
+                Assert.AreEqual(SocketError.ConnectionAborted, ex.SocketErrorCode);
+            }
+        }
+
+        /// <summary>
         /// Starts the client.
         /// </summary>
         private static IIgniteClient StartClient()
index 8e19df5..f9e77fc 100644 (file)
@@ -590,7 +590,11 @@ namespace Apache.Ignite.Core.Impl.Client
                 _socket.Dispose();
                 _listenerEvent.Set();
                 _listenerEvent.Dispose();
-                _timeoutCheckTimer.Dispose();
+
+                if (_timeoutCheckTimer != null)
+                {
+                    _timeoutCheckTimer.Dispose();
+                }
 
                 // Wait for lock to be released and dispose.
                 if (!_sendRequestLock.IsWriteLockHeld)