Browse Source

ZOOKEEPER-272. getchildren can fail for large number of children. (mahadev)

git-svn-id: https://svn.apache.org/repos/asf/hadoop/zookeeper/trunk@739079 13f79535-47bb-0310-9956-ffa450edef68
Mahadev Konar 16 years ago
parent
commit
bd67906b1d
2 changed files with 6 additions and 1 deletions
  1. 2 0
      CHANGES.txt
  2. 4 1
      src/java/main/org/apache/zookeeper/ClientCnxn.java

+ 2 - 0
CHANGES.txt

@@ -76,6 +76,8 @@ and runping via mahadev)
   ZOOKEEPER-263. document connection host:port as comma separated list in forrest docs (pat via breed)
   
   ZOOKEEPER-275. Bug in FastLeaderElection. (flavio via mahadev)
+
+  ZOOKEEPER-272. getchildren can fail for large number of children. (mahadev)
  
 IMPROVEMENTS:
    

+ 4 - 1
src/java/main/org/apache/zookeeper/ClientCnxn.java

@@ -81,12 +81,15 @@ public class ClientCnxn {
      * option allows the client to turn off this behavior by setting
      * the environment variable "zookeeper.disableAutoWatchReset" to "true" */
     public static boolean disableAutoWatchReset;
+   
+    public static int packetLen;
     static {
         // this var should not be public, but otw there is no easy way 
         // to test
         disableAutoWatchReset = 
             Boolean.getBoolean("zookeeper.disableAutoWatchReset");
         LOG.info("zookeeper.disableAutoWatchReset is " + disableAutoWatchReset);
+        packetLen = Integer.getInteger("jute.maxbuffer", 4096 * 1024);
     }
 
     private ArrayList<InetSocketAddress> serverAddrs = new ArrayList<InetSocketAddress>();
@@ -502,7 +505,7 @@ public class ClientCnxn {
 
         void readLength() throws IOException {
             int len = incomingBuffer.getInt();
-            if (len < 0 || len >= 4096 * 1024) {
+            if (len < 0 || len >= packetLen) {
                 throw new IOException("Packet len" + len + " is out of range!");
             }
             incomingBuffer = ByteBuffer.allocate(len);