MINA
  1. MINA
  2. DIRMINA-803

ProtocolCodecFilter.filterWrite() is no longer thread-safe

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: 2.0.1
    • Component/s: Filter
    • Labels:
      None

      Description

      In revision 'r912149 | elecharny | 2010-02-20 22:04:32 +0500 (Sat, 20 Feb 2010)' the loop that flushes the encoded messages was modified and is no longer thread-safe. In the trunk the queue is checked if it is empty then polled for the next element. Between these calls another thread could have taken the last element in the queue and the element is not checked if it is null.

      Starting at line 328:

      while (!bufferQueue.isEmpty()) {
      Object encodedMessage = bufferQueue.poll();
      ...

      could be replaced with the previous loop:

      for (; {
      Object encodedMessage = bufferQueue.poll();
      if (encodedMessage == null)

      { break; }

      ...

      to make the method thread-safe again.

      The same issue exists in ProtocolEncoderOutputImpl.flush().

        Activity

        Hide
        Emmanuel Lecharny added a comment -

        Closing issues

        Show
        Emmanuel Lecharny added a comment - Closing issues
        Show
        Emmanuel Lecharny added a comment - Fixed with : http://svn.apache.org/viewvc?rev=1023759&view=rev
        Hide
        Emmanuel Lecharny added a comment -

        You are right !

        When I removed the flushWithoutFuture() method and merged its code, I simply ignored the test for nulity.

        My bad ! Will fix it in trunk, and probably release a MINA 2.0.1 asap

        Thanks for the report !

        Show
        Emmanuel Lecharny added a comment - You are right ! When I removed the flushWithoutFuture() method and merged its code, I simply ignored the test for nulity. My bad ! Will fix it in trunk, and probably release a MINA 2.0.1 asap Thanks for the report !

          People

          • Assignee:
            Unassigned
            Reporter:
            Stuart Scott
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development