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 3b4453d..8c9fbf5 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 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;
     }
   }