THRIFT-1412 Thrift Transport classes should manage the lifetime of objects implementing IDisposable by implementing IDisposable themselves
Patch: Joshua Garvin

git-svn-id: https://svn.apache.org/repos/asf/thrift/trunk@1325013 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/csharp/src/Server/TThreadedServer.cs b/lib/csharp/src/Server/TThreadedServer.cs
index f2be073..8e73bb7 100644
--- a/lib/csharp/src/Server/TThreadedServer.cs
+++ b/lib/csharp/src/Server/TThreadedServer.cs
@@ -185,14 +185,18 @@
 			TProtocol outputProtocol = null;
 			try
 			{
-				inputTransport = inputTransportFactory.GetTransport(client);
-				outputTransport = outputTransportFactory.GetTransport(client);
-				inputProtocol = inputProtocolFactory.GetProtocol(inputTransport);
-				outputProtocol = outputProtocolFactory.GetProtocol(outputTransport);
-				while (processor.Process(inputProtocol, outputProtocol))
-				{
-					//keep processing requests until client disconnects
-				}
+        using (inputTransport = inputTransportFactory.GetTransport(client))
+        {
+          using (outputTransport = outputTransportFactory.GetTransport(client))
+          {
+            inputProtocol = inputProtocolFactory.GetProtocol(inputTransport);
+            outputProtocol = outputProtocolFactory.GetProtocol(outputTransport);
+            while (processor.Process(inputProtocol, outputProtocol))
+            {
+              //keep processing requests until client disconnects
+            }
+          }
+        }
 			}
 			catch (TTransportException)
 			{
@@ -202,15 +206,6 @@
 				logDelegate("Error: " + x);
 			}
 
-			if (inputTransport != null)
-			{
-				inputTransport.Close();
-			}
-			if (outputTransport != null)
-			{
-				outputTransport.Close();
-			}
-
 			lock (clientLock)
 			{
 				clientThreads.Remove(Thread.CurrentThread);