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/TSimpleServer.cs b/lib/csharp/src/Server/TSimpleServer.cs
index c6fd99e..1099fc1 100644
--- a/lib/csharp/src/Server/TSimpleServer.cs
+++ b/lib/csharp/src/Server/TSimpleServer.cs
@@ -95,39 +95,35 @@
 				TProtocol outputProtocol = null;
 				try
 				{
-					client = serverTransport.Accept();
-					if (client != null)
-					{
-						inputTransport = inputTransportFactory.GetTransport(client);
-						outputTransport = outputTransportFactory.GetTransport(client);
-						inputProtocol = inputProtocolFactory.GetProtocol(inputTransport);
-						outputProtocol = outputProtocolFactory.GetProtocol(outputTransport);
-						while (processor.Process(inputProtocol, outputProtocol)) { }
-					}
-				}
-				catch (TTransportException ttx)
-				{
-					// Client died, just move on
-					if (stop)
-					{
-						logDelegate("TSimpleServer was shutting down, caught " + ttx.GetType().Name);
-					}
-				}
-				catch (Exception x)
-				{
-					logDelegate(x.ToString());
-				}
-
-				if (inputTransport != null)
-				{
-					inputTransport.Close();
-				}
-
-				if (outputTransport != null)
-				{
-					outputTransport.Close();
-				}
-			}
+          using(client = serverTransport.Accept())
+          {
+            if (client != null)
+            {
+              using(inputTransport = inputTransportFactory.GetTransport(client))
+              {
+                using (outputTransport = outputTransportFactory.GetTransport(client))
+                {
+                  inputProtocol = inputProtocolFactory.GetProtocol(inputTransport);
+                  outputProtocol = outputProtocolFactory.GetProtocol(outputTransport);
+                  while (processor.Process(inputProtocol, outputProtocol)) { }
+                }
+              }
+            }
+          }
+        }
+        catch (TTransportException ttx)
+        {
+          // Client died, just move on
+          if (stop)
+          {
+            logDelegate("TSimpleServer was shutting down, caught " + ttx.GetType().Name);
+          }
+        }
+        catch (Exception x)
+        {
+          logDelegate(x.ToString());
+        }
+      }
 
 			if (stop)
 			{