Hi All,

First patch submission for me.  If there are any patch submission
guidelines I should follow, kindly point me at them and accept my
apology if this approach violates any established procedures.  I didn't
find anything obvious on the site wiki, so I just used some practices
learned on other projects.

-Greg

------------------------

commit 840f56d388582e1df39f7513aa7f4d4ce0610718
Author: Gregory Haskins <ghask...@novell.com>
Date:   Fri May 21 14:58:14 2010 -0400

    javaclient: validate sessionTimeout field at ZooKeeper init
   
    JIRA ZOOKEEPER-776 describes the following problem:
    
    passing in a "0" sessionTimeout to ZooKeeper() constructor leads to
errors
    in subsequent operations. It would be ideal to capture this
configuration
    error at the source by throwing something like an IllegalArgument
exception
    when the bogus sessionTimeout is specified, instead of later when it is
    utilized.
    
    This patch is a proposal to fix the problem referenced above.

    Applies to svn-id: 946074
    
    Signed-off-by: Gregory Haskins <ghask...@novell.com>

diff --git a/src/java/main/org/apache/zookeeper/ClientCnxn.java
b/src/java/main/
index 8eb227d..682811b 100644
--- a/src/java/main/org/apache/zookeeper/ClientCnxn.java
+++ b/src/java/main/org/apache/zookeeper/ClientCnxn.java
@@ -353,6 +353,11 @@ public class ClientCnxn {
         this.sessionId = sessionId;
         this.sessionPasswd = sessionPasswd;
 
+       if (sessionTimeout <= 0) {
+           throw new IOException("sessionTimeout " + sessionTimeout
+                                 + " is not valid");
+       }
+
         // parse out chroot, if any
         int off = hosts.indexOf('/');
         if (off >= 0) {

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to