From: Jens Geyer Date: Thu, 2 Jan 2014 21:58:43 +0000 (+0100) Subject: THRIFT-2303 TBufferredTransport not properly closing underlying transport X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=f6acf44117ebc96dff9eded7a836674be9924d84;p=common%2Fthrift.git THRIFT-2303 TBufferredTransport not properly closing underlying transport Patch: Alex Ausch --- diff --git a/lib/csharp/src/Transport/TBufferedTransport.cs b/lib/csharp/src/Transport/TBufferedTransport.cs index 14b5db06..6cb0457a 100644 --- a/lib/csharp/src/Transport/TBufferedTransport.cs +++ b/lib/csharp/src/Transport/TBufferedTransport.cs @@ -54,6 +54,18 @@ namespace Thrift.Transport } } + private void CloseBuffers() + { + if (inputBuffer != null && inputBuffer.CanRead) + { + inputBuffer.Close(); + } + if (outputBuffer != null && outputBuffer.CanWrite) + { + outputBuffer.Close(); + } + } + public TTransport UnderlyingTransport { get { return transport; } @@ -72,14 +84,8 @@ namespace Thrift.Transport public override void Close() { - if (inputBuffer != null && inputBuffer.CanRead) - { - inputBuffer.Close(); - } - if (outputBuffer != null && outputBuffer.CanWrite) - { - outputBuffer.Close(); - } + CloseBuffers(); + transport.Close(); } public override int Read(byte[] buf, int off, int len) diff --git a/lib/csharp/test/ThriftTest/TestClient.cs b/lib/csharp/test/ThriftTest/TestClient.cs index fe21f41c..c7b81b4c 100644 --- a/lib/csharp/test/ThriftTest/TestClient.cs +++ b/lib/csharp/test/ThriftTest/TestClient.cs @@ -99,7 +99,10 @@ namespace Test trans = new TBufferedTransport(trans as TStreamTransport); if (framed) trans = new TFramedTransport(trans); - + + //ensure proper open/close of transport + trans.Open(); + trans.Close(); t.Start(trans); } else