{"action":"created","issue":{"url":"https://api.github.com/repos/sgroschupf/zkclient/issues/25","labels_url":"https://api.github.com/repos/sgroschupf/zkclient/issues/25/labels{/name}","comments_url":"https://api.github.com/repos/sgroschupf/zkclient/issues/25/comments","events_url":"https://api.github.com/repos/sgroschupf/zkclient/issues/25/events","html_url":"https://github.com/sgroschupf/zkclient/issues/25","id":35098483,"number":25,"title":"NullPointerException possibility during reconnection","user":{"login":"noslowerdna","id":930946,"avatar_url":"https://avatars.githubusercontent.com/u/930946?v=3","gravatar_id":"","url":"https://api.github.com/users/noslowerdna","html_url":"https://github.com/noslowerdna","followers_url":"https://api.github.com/users/noslowerdna/followers","following_url":"https://api.github.com/users/noslowerdna/following{/other_user}","gists_url":"https://api.github.com/users/noslowerdna/gists{/gist_id}","starred_url":"https://api.github.com/users/noslowerdna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noslowerdna/subscriptions","organizations_url":"https://api.github.com/users/noslowerdna/orgs","repos_url":"https://api.github.com/users/noslowerdna/repos","events_url":"https://api.github.com/users/noslowerdna/events{/privacy}","received_events_url":"https://api.github.com/users/noslowerdna/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2014-06-05T21:13:23Z","updated_at":"2015-09-24T19:14:10Z","closed_at":"2015-04-30T15:18:37Z","body":"It appears that a NullPointerException can be thrown if the ZkClient is being used while a state change requiring a reconnection is being processed.\r\n\r\nSee https://issues.apache.org/jira/browse/KAFKA-824?focusedCommentId=14019284&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-14019284 for example stack traces and a preliminary analysis of the problem."},"comment":{"url":"https://api.github.com/repos/sgroschupf/zkclient/issues/comments/143022918","html_url":"https://github.com/sgroschupf/zkclient/issues/25#issuecomment-143022918","issue_url":"https://api.github.com/repos/sgroschupf/zkclient/issues/25","id":143022918,"user":{"login":"hachikuji","id":12502538,"avatar_url":"https://avatars.githubusercontent.com/u/12502538?v=3","gravatar_id":"","url":"https://api.github.com/users/hachikuji","html_url":"https://github.com/hachikuji","followers_url":"https://api.github.com/users/hachikuji/followers","following_url":"https://api.github.com/users/hachikuji/following{/other_user}","gists_url":"https://api.github.com/users/hachikuji/gists{/gist_id}","starred_url":"https://api.github.com/users/hachikuji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hachikuji/subscriptions","organizations_url":"https://api.github.com/users/hachikuji/orgs","repos_url":"https://api.github.com/users/hachikuji/repos","events_url":"https://api.github.com/users/hachikuji/events{/privacy}","received_events_url":"https://api.github.com/users/hachikuji/received_events","type":"User","site_admin":false},"created_at":"2015-09-24T19:14:10Z","updated_at":"2015-09-24T19:14:10Z","body":"@jzillmann One user is still seeing similar NPEs in ZkConnection.java after upgrading to 0.5. The patch appears to address the race condition around ZkClient.close(), but isn't there still a case where reconnect could cause the Zookeeper reference in ZkConnection to be set to null just before retrying in retryUntilConnected? Unless I'm misunderstanding the code (which is definitely possible), it looks like reconnect is called from the zookeeper event thread, so between the time that ZkConnection.close() and the connection is reestablished in ZkConnection.connect(), what prevents the user from seeing a null Zookeeper in ZkConnection? Maybe I'm missing something?"}}