THRIFT-2339 Uncaught exception in thrift c# driver
authorJens Geyer <jensg@apache.org>
Tue, 18 Mar 2014 22:21:49 +0000 (00:21 +0200)
committerJens Geyer <jensg@apache.org>
Tue, 18 Mar 2014 22:21:49 +0000 (00:21 +0200)
Patch: Janis Ser
Github Pull Request: This closes #79
----
commit d650ca3380aac39eae1f17dc72d4097eb3394562
Author: JSSTR <janis.sermulins@struq.com>
Date:   2014-01-29T13:49:51Z

    Update TSocket.cs

    Make sure to catch all exceptions in the ConnectCallback.

----

lib/csharp/src/Transport/TSocket.cs

index 7717cfb..35fbe97 100644 (file)
@@ -177,16 +177,21 @@ namespace Thrift.Transport
                     if( hlp.Client.Client != null)
                         hlp.Client.EndConnect(asyncres);
                 }
-                catch (SocketException)
+                catch (Exception)
                 {
                     // catch that away
                 }
 
                 if (hlp.DoCleanup) 
                 {
-                    asyncres.AsyncWaitHandle.Close();
-                    if (hlp.Client is IDisposable)
-                        ((IDisposable)hlp.Client).Dispose();
+                       try {
+                       asyncres.AsyncWaitHandle.Close();
+                       } catch (Exception) {}
+                       
+                       try {
+                       if (hlp.Client is IDisposable)
+                               ((IDisposable)hlp.Client).Dispose();
+                       } catch (Exception) {}
                     hlp.Client = null;
                 }
             }