You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by "Raul Gutierrez Segales (JIRA)" <ji...@apache.org> on 2014/07/21 00:36:38 UTC
[jira] [Commented] (ZOOKEEPER-1978) Fix
AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION
[ https://issues.apache.org/jira/browse/ZOOKEEPER-1978?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14068066#comment-14068066 ]
Raul Gutierrez Segales commented on ZOOKEEPER-1978:
---------------------------------------------------
But that happens inside a synchronized method though...:
{noformat}
public synchronized boolean addSession
{noformat}
still, I guess putIfAbsent is better.
> Fix AT_OPERATION_SEQUENCE_ON_CONCURRENT_ABSTRACTION
> ---------------------------------------------------
>
> Key: ZOOKEEPER-1978
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-1978
> Project: ZooKeeper
> Issue Type: Sub-task
> Reporter: Hongchao Deng
> Assignee: Hongchao Deng
> Priority: Minor
> Fix For: 3.5.0
>
>
> findbugs is complaining
> {code}
> if (sessionsById.get(id) == null) {
> SessionImpl s = new SessionImpl(id, sessionTimeout);
> sessionsById.put(id, s);
> }
> {code}
> is not atomic for the gap between get() and put().
> I suggest using putIfAbsent() instead.
--
This message was sent by Atlassian JIRA
(v6.2#6252)