[ 
https://issues.apache.org/jira/browse/ZOOKEEPER-1683?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14052952#comment-14052952
 ] 

Rakesh R commented on ZOOKEEPER-1683:
-------------------------------------

Sorry for pitch in late. Thanks [~shralex] for the patch. Could you please 
correct the code format too.

1) {code} +        if (tmp!=null) { {code}
could be {code} if (tmp != null) { {code}

2) {code} if (lastIndex >=0) { {code}
could be  {code} if (lastIndex >= 0) { {code}

3) Moved the sync block to method level. I hope you have skipped the formatting 
of this code section just to reduce the changes in patch, but I'd prefer to 
correct this section too.
{code}
-        synchronized(this) {
{code}

4) {code} addr.getAddress()!=null && myServer.getAddress()!=null {code}
could be {code} addr.getAddress() != null && myServer.getAddress() != null 
{code}

5) I could see tabs in many places, please use spaces instead of this. Below is 
one such case.
{code}
+        // if the client is not currently connected to any server
+        if (myServer == null) {
+               // reconfigMode = false (next shouldn't return null).           
+                       if (lastIndex >=0) {
+               // take the last server to which we were connected
+                               myServer = this.serverAddresses.get(lastIndex);
+                       }
+                       else {
+                               // take the first server on the list
+                               myServer = this.serverAddresses.get(0);
+                       }
{code}


6) Also, I could see many whitespaces in the patch. Kindly remove these. Below 
are few such cases:
{code}
+        
+        InetSocketAddress myServer = currentHost;
+        
{code}
{code}
+            lastIndex = currentIndex;              
{code}
{code}
+        newList = getServerAddresses((byte) 9);
+        
+        for (int i = 0; i < numClients; i++) {
{code}

> ZooKeeper client NPE when updating server list on disconnected client
> ---------------------------------------------------------------------
>
>                 Key: ZOOKEEPER-1683
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-1683
>             Project: ZooKeeper
>          Issue Type: Bug
>          Components: java client
>    Affects Versions: 3.5.0
>            Reporter: Shevek
>            Assignee: Alexander Shraer
>             Fix For: 3.5.0
>
>         Attachments: ZOOKEEPER-1683-ver1.patch, ZOOKEEPER-1683-ver2.patch, 
> ZOOKEEPER-1683-ver2.patch, ZOOKEEPER-1683-ver5.patch, 
> ZOOKEEPER-1683-ver5.patch, ZOOKEEPER-1683-ver6.patch, ZOOKEEPER-1683.patch
>
>
> 2013-04-04 22:16:15,872 ERROR [pool-4-thread-1] 
> com.netflix.curator.ConnectionState.getZooKeeper (ConnectionState.java:84) - 
> Background exception caught
> java.lang.NullPointerException
>         at 
> org.apache.zookeeper.client.StaticHostProvider.updateServerList(StaticHostProvider.java:161)
>  ~[zookeeper-3.5.0.jar:3.5.0--1]
>         at 
> org.apache.zookeeper.ZooKeeper.updateServerList(ZooKeeper.java:183) 
> ~[zookeeper-3.5.0.jar:3.5.0--1]
>         at 
> com.netflix.curator.HandleHolder$1$1.setConnectionString(HandleHolder.java:121)
>  ~[curator-client-1.3.5-SNAPSHOT.jar:?]
> The duff code is this:
> ClientCnxnSocket clientCnxnSocket = cnxn.sendThread.getClientCnxnSocket();
> InetSocketAddress currentHost = (InetSocketAddress) 
> clientCnxnSocket.getRemoteSocketAddress();
> boolean reconfigMode = hostProvider.updateServerList(serverAddresses, 
> currentHost);
> Now, currentHost might be null, if we're not yet connected. But 
> StaticHostProvider.updateServerList indirects on it unconditionally.
> This would be caught by findbugs.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to