Uploaded image for project: 'Qpid'
  1. Qpid
  2. QPID-2653

Double checked locking in org.apache.qpid.server.transport.ThreadPoolFilter

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Duplicate
    • Affects Version/s: 0.7
    • Fix Version/s: 0.7
    • Component/s: Java Broker
    • Labels:
      None

      Description

      org.apache.qpid.server.transport.ThreadPoolFilter has a double check locking in this method:

      private SessionBuffer getSessionBuffer(IoSession session)
      {
      final Map buffers = this.buffers;
      SessionBuffer buf = (SessionBuffer) buffers.get(session);
      if (buf == null)
      {
      synchronized (buffers)
      {
      buf = (SessionBuffer) buffers.get(session);
      if (buf == null)

      { buf = new SessionBuffer(session); buffers.put(session, buf); }

      }
      }
      return buf;
      }

        Issue Links

          Activity

          Hide
          gemmellr Robbie Gemmell added a comment -

          The original code, whilst a bit odd looking, does ensure that only 1 new buffer is added to the map. The patch does not, as it synchronizes after checking whether tehre was anything in the map and so multiple threads waiting on the lock could then add to the map. I would look at synchronizing/locking around the get and put.

          Show
          gemmellr Robbie Gemmell added a comment - The original code, whilst a bit odd looking, does ensure that only 1 new buffer is added to the map. The patch does not, as it synchronizes after checking whether tehre was anything in the map and so multiple threads waiting on the lock could then add to the map. I would look at synchronizing/locking around the get and put.
          Hide
          sorins Sorin Suciu added a comment -

          Agreed Robbie, here comes a better patch I hope.

          Show
          sorins Sorin Suciu added a comment - Agreed Robbie, here comes a better patch I hope.
          Hide
          andrew.kennedy Andrew Kennedy added a comment -

          Duplicate of QPID-2757

          Show
          andrew.kennedy Andrew Kennedy added a comment - Duplicate of QPID-2757

            People

            • Assignee:
              sorins Sorin Suciu
              Reporter:
              sorins Sorin Suciu
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development