Patrick Hunt commented on ZOOKEEPER-666:

Martin, yes, that is a good idea. (you picked a good jira ID number for this 
one btw ;-) )

So to subclass ZooKeeper the user would just create their own builder? Or 
subclass builder and cast if necessary?

Is the builder approach "container friendly"? I haven't looked at spring and 
such (di/ioc) lately but my setter idea was along the
lines of allowing easy integration with those types of frameworks. I guess 
builder is essentially just another class with setter methods?
I'd really like to get some kind of container support tested out and in 
particular setup as a unit test in ZK so we can "officially"
support, perhaps we should do that as part of this change.

> 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.3.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 is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

Reply via email to