Qpid
  1. Qpid
  2. QPID-2653

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

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor 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
          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
          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
          Sorin Suciu added a comment -

          Agreed Robbie, here comes a better patch I hope.

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

          Duplicate of QPID-2757

          Show
          Andrew Kennedy added a comment - Duplicate of QPID-2757

            People

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

              Dates

              • Created:
                Updated:
                Resolved:

                Development