[ https://issues.apache.org/jira/browse/ZOOKEEPER-1861?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13898637#comment-13898637 ]
Camille Fournier commented on ZOOKEEPER-1861: --------------------------------------------- Actually, I'm going to go back on this. The whole point of using a concurrent data structure is so we don't synchronize on this operation. Which means we have to allocate potentially unnecessarily. I prefer patch v2. If you really want to try and not worry about allocation, check for existence, then create, and put if not absent, but meh. I don't know that I care about an (unlikely) extra allocation. > ConcurrentHashMap isn't used properly in QuorumCnxManager > --------------------------------------------------------- > > Key: ZOOKEEPER-1861 > URL: https://issues.apache.org/jira/browse/ZOOKEEPER-1861 > Project: ZooKeeper > Issue Type: Bug > Reporter: Ted Yu > Assignee: Ted Yu > Priority: Minor > Attachments: zookeeper-1861-v1.txt, zookeeper-1861-v2.txt, > zookeeper-1861-v3.txt > > > queueSendMap is a ConcurrentHashMap. > At line 210: > {code} > if (!queueSendMap.containsKey(sid)) { > queueSendMap.put(sid, new ArrayBlockingQueue<ByteBuffer>( > SEND_CAPACITY)); > {code} > By the time control enters if block, there may be another concurrent put with > same sid to the ConcurrentHashMap. > putIfAbsent() should be used. > Similar issue occurs at line 307 as well. -- This message was sent by Atlassian JIRA (v6.1.5#6160)