From 7e36df1c07dda74187ad53ea1ff2d037fb3a67e5 Mon Sep 17 00:00:00 2001 From: David Reiss Date: Mon, 26 Apr 2010 19:37:53 +0000 Subject: [PATCH] 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 --- .../org/apache/thrift/protocol/TBinaryProtocol.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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; } } -- 2.17.1