From: David Reiss Date: Mon, 26 Apr 2010 19:37:53 +0000 (+0000) Subject: THRFIT-601. java: Add readLength support to TBinaryProtocol.Factory X-Git-Tag: 0.3.0~28 X-Git-Url: https://source.supwisdom.com/gerrit/gitweb?a=commitdiff_plain;h=7e36df1c07dda74187ad53ea1ff2d037fb3a67e5;p=common%2Fthrift.git THRFIT-601. java: Add readLength support to TBinaryProtocol.Factory git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@938206 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/lib/java/src/org/apache/thrift/protocol/TBinaryProtocol.java b/lib/java/src/org/apache/thrift/protocol/TBinaryProtocol.java index 3b4453dc..8c9fbf51 100644 --- a/lib/java/src/org/apache/thrift/protocol/TBinaryProtocol.java +++ b/lib/java/src/org/apache/thrift/protocol/TBinaryProtocol.java @@ -45,18 +45,28 @@ public class TBinaryProtocol extends TProtocol { public static class Factory implements TProtocolFactory { protected boolean strictRead_ = false; protected boolean strictWrite_ = true; + protected int readLength_; public Factory() { this(false, true); } public Factory(boolean strictRead, boolean strictWrite) { + this(strictRead, strictWrite, 0); + } + + public Factory(boolean strictRead, boolean strictWrite, int readLength) { strictRead_ = strictRead; strictWrite_ = strictWrite; + readLength_ = readLength; } public TProtocol getProtocol(TTransport trans) { - return new TBinaryProtocol(trans, strictRead_, strictWrite_); + TBinaryProtocol proto = new TBinaryProtocol(trans, strictRead_, strictWrite_); + if (readLength_ != 0) { + proto.setReadLength(readLength_); + } + return proto; } }