Uploaded image for project: 'ZooKeeper'
  1. ZooKeeper
  2. ZOOKEEPER-1861

ConcurrentHashMap isn't used properly in QuorumCnxManager

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.5.0
    • 3.5.0
    • None
    • None

    Description

      queueSendMap is a ConcurrentHashMap.
      At line 210:

                  if (!queueSendMap.containsKey(sid)) {
                      queueSendMap.put(sid, new ArrayBlockingQueue<ByteBuffer>(
                              SEND_CAPACITY));
      

      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.

      Attachments

        1. zookeeper-1861-v3.txt
          3 kB
          Ted Yu
        2. zookeeper-1861-v2.txt
          2 kB
          Ted Yu
        3. zookeeper-1861-v1.txt
          0.7 kB
          Ted Yu

        Activity

          People

            zhihyu@ebaysf.com Ted Yu
            yuzhihong@gmail.com Ted Yu
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: