Uploaded image for project: 'MINA'
  1. MINA
  2. DIRMINA-598

ByteBuffer passed to ProtocolEncoderOutput.write(ByteBuffer) does not get released back to the pool

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Won't Fix
    • 1.1.7
    • 1.1.8
    • Filter
    • None

    Description

      When pooled ByteBuffers are used in conjunction with a ProtocolCodecFilter, buffers passed to ProtocolEncoderOutput.write() do not get released back to the pool in all circumstances, causing unnecessary memory allocation.

      The following patch appears to resolve this issue in a simple filter chain, but it should be verified that there is no case where this change would cause a buffer to be released too early.

      Best regards,
      Greg

      Index: core/src/main/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java
      ===================================================================
      — core/src/main/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java (revision 657929)
      +++ core/src/main/java/org/apache/mina/filter/codec/ProtocolCodecFilter.java (working copy)
      @@ -186,6 +186,10 @@
      public void messageSent(NextFilter nextFilter, IoSession session,
      Object message) throws Exception {
      if (message instanceof HiddenByteBuffer)

      { + // Release buffer originally passed to ProtocolEncoderOutput.write(ByteBuffer) + // See http://mina.apache.org/report/1.1/apidocs/org/apache/mina/common/ByteBuffer.html + ((HiddenByteBuffer) message).release(); + return; }

      Attachments

        Activity

          People

            Unassigned Unassigned
            gdhuse Greg Dhuse
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: