You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by "Michi Mutsuzaki (JIRA)" <ji...@apache.org> on 2014/04/24 00:34:16 UTC
[jira] [Updated] (ZOOKEEPER-666) Unsafe publication in client API
[ https://issues.apache.org/jira/browse/ZOOKEEPER-666?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Michi Mutsuzaki updated ZOOKEEPER-666:
--------------------------------------
Fix Version/s: (was: 3.5.0)
3.6.0
> Unsafe publication in client API
> --------------------------------
>
> Key: ZOOKEEPER-666
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-666
> Project: ZooKeeper
> Issue Type: Bug
> Components: java client
> Affects Versions: 3.2.2
> Reporter: Martin Traverso
> Fix For: 3.6.0
>
>
> 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.
> {noformat}
> public ZooKeeper(String connectString, int sessionTimeout, Watcher watcher)
> throws IOException
> {
> .....
> cnxn = new ClientCnxn(connectString, sessionTimeout, this, watchManager);
> cnxn.start();
> }
> {noformat}
> The obvious fix is to move the call to cnxn.start() into a separate start() method.
--
This message was sent by Atlassian JIRA
(v6.2#6252)