[
https://issues.apache.org/jira/browse/ZOOKEEPER-666?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12832392#action_12832392
]
Patrick Hunt commented on ZOOKEEPER-666:
----------------------------------------
Yes, the subclassing issue in particular is nasty. We've fixed a number of
these in the server
implementation already (not all iirc). In this case I'm not sure if we can do
it in 3.3.0 though. It's too
near term and the solution for this is going to be disruptive - the main public
client interface needs
to be changed.
I suspect that we should
1) deprecate the existing constructors
2a) either add a new empty constructor and a "connect(connect, watcher,timeout)
or
2b) add a new empty constructor, methods; setconnect/setwatcher(have
alredy)/settimeout, and a connect() string
(or perhaps connect(connectstring), etc...) One nice thing about this rather
than 2a is that we can add new
parameters in future w/o changing/overloading the
connect(param1,param2,param3,...) method
existing users can migrate as they like (old methods deprecated)
> 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.