Updated Branches: refs/heads/master 56d41eb4a -> 213ea258d
THRIFT-1457 java: Capacity of TframedTransport write buffer is never reset Patch: Arthur Meyer Project: http://git-wip-us.apache.org/repos/asf/thrift/repo Commit: http://git-wip-us.apache.org/repos/asf/thrift/commit/213ea258 Tree: http://git-wip-us.apache.org/repos/asf/thrift/tree/213ea258 Diff: http://git-wip-us.apache.org/repos/asf/thrift/diff/213ea258 Branch: refs/heads/master Commit: 213ea258de6796e1302e57f4246434ca3c9a2ac6 Parents: 56d41eb Author: Roger Meier <[email protected]> Authored: Thu Feb 6 23:41:37 2014 +0100 Committer: Roger Meier <[email protected]> Committed: Thu Feb 6 23:41:37 2014 +0100 ---------------------------------------------------------------------- .../src/org/apache/thrift/TByteArrayOutputStream.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/thrift/blob/213ea258/lib/java/src/org/apache/thrift/TByteArrayOutputStream.java ---------------------------------------------------------------------- diff --git a/lib/java/src/org/apache/thrift/TByteArrayOutputStream.java b/lib/java/src/org/apache/thrift/TByteArrayOutputStream.java index 9ed83c0..1c37ecd 100644 --- a/lib/java/src/org/apache/thrift/TByteArrayOutputStream.java +++ b/lib/java/src/org/apache/thrift/TByteArrayOutputStream.java @@ -27,18 +27,29 @@ import java.io.ByteArrayOutputStream; * */ public class TByteArrayOutputStream extends ByteArrayOutputStream { + + private final int initialSize; + public TByteArrayOutputStream(int size) { super(size); + this.initialSize = size; } public TByteArrayOutputStream() { - super(); + this(32); } public byte[] get() { return buf; } + public void reset() { + super.reset(); + if (buf.length > initialSize) { + buf = new byte[initialSize]; + } + } + public int len() { return count; }
