You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by je...@apache.org on 2014/01/02 22:59:10 UTC
git commit: THRIFT-2303 TBufferredTransport not properly closing
underlying transport
Updated Branches:
refs/heads/master 2136694a2 -> f6acf4411
THRIFT-2303 TBufferredTransport not properly closing underlying transport
Patch: Alex Ausch
Project: http://git-wip-us.apache.org/repos/asf/thrift/repo
Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/f6acf441
Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/f6acf441
Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/f6acf441
Branch: refs/heads/master
Commit: f6acf44117ebc96dff9eded7a836674be9924d84
Parents: 2136694
Author: Jens Geyer <je...@apache.org>
Authored: Thu Jan 2 22:58:43 2014 +0100
Committer: Jens Geyer <je...@apache.org>
Committed: Thu Jan 2 22:58:43 2014 +0100
----------------------------------------------------------------------
lib/csharp/src/Transport/TBufferedTransport.cs | 22 +++++++++++++--------
lib/csharp/test/ThriftTest/TestClient.cs | 5 ++++-
2 files changed, 18 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/thrift/blob/f6acf441/lib/csharp/src/Transport/TBufferedTransport.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/src/Transport/TBufferedTransport.cs b/lib/csharp/src/Transport/TBufferedTransport.cs
index 14b5db0..6cb0457 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)
http://git-wip-us.apache.org/repos/asf/thrift/blob/f6acf441/lib/csharp/test/ThriftTest/TestClient.cs
----------------------------------------------------------------------
diff --git a/lib/csharp/test/ThriftTest/TestClient.cs b/lib/csharp/test/ThriftTest/TestClient.cs
index fe21f41..c7b81b4 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