Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
3.2.2
-
None
-
None
Description
The following code may result in a data race due to unsafe publication of a reference to "this". The call to cnxn.start() spawns threads that have access to the partially-constructed reference to the ZooKeeper object.
See http://www.ibm.com/developerworks/java/library/j-jtp0618.html for some background info.
public ZooKeeper(String connectString, int sessionTimeout, Watcher watcher) throws IOException { ..... cnxn = new ClientCnxn(connectString, sessionTimeout, this, watchManager); cnxn.start(); }
The obvious fix is to move the call to cnxn.start() into a separate start() method.
Attachments
Issue Links
- is cloned by
-
ZOOKEEPER-837 cyclic dependency ClientCnxn, ZooKeeper
- Closed
- is related to
-
ZOOKEEPER-835 Refactoring Zookeeper Client Code
- Open