I recognised that ByteBuffer from the PooledByteBufferAllocator are
not always initialized with 0. If a buffer gets reused the old value
is still present. In my understanding it would be necessary to clear
previous data if a buffer is reused.

The following program shows the issue:

import org.apache.mina.common.ByteBuffer;

public class PooledByteBufferTest {

        public static void main(String[] args) {
                ByteBuffer buffer1 = ByteBuffer.allocate(100);
                System.out.println("buffer1[0]=" + buffer1.getInt(0)); // 
prints 0
                buffer1.putInt(42);
                System.out.println("buffer1[0]=" + buffer1.getInt(0)); // 
prints 42
                buffer1.release();

                ByteBuffer buffer2 = ByteBuffer.allocate(100);
                System.out.println("buffer1[0]=" + buffer2.getInt(0)); // 
prints 42
but should print 0
        }
}

In my opinion this is not the desired behaviour.

Stefan

MINA 1.1.6

Reply via email to