[ https://issues.apache.org/jira/browse/DIRMINA-664?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12677093#action_12677093 ]
David Rosenstrauch commented on DIRMINA-664: -------------------------------------------- ? Not sure I understand. I'm never calling expand() on the buffer, and so I'm getting erroneous data behavior. (You can see this if you run my unit tests. The tests are failing!) Seems like a big deal to me - especially the part pertaining to IoBuffer.allocate(0).setAutoExpand(true). It caused some bugs in my system whereby I thought I was getting allocated a new buffer, but instead Mina was giving me an existing buffer that already had data in it. Just my $0.02, but IMO using expandable buffers isn't the problem here, but rather keeping some buffers around as static constants. The assumption there is that you can hold them as static constants since they're immutable, but as you can see that assumption of immutability is not correct. IMO, the fix here is to get rid of the static constants, and have IoBuffer allocate you a new one each time. > EMPTY_* IoBuffer constants can be made mutable and cause data errors > -------------------------------------------------------------------- > > Key: DIRMINA-664 > URL: https://issues.apache.org/jira/browse/DIRMINA-664 > Project: MINA > Issue Type: Bug > Components: Core > Affects Versions: 2.0.0-M4 > Environment: All? > Reporter: David Rosenstrauch > Priority: Minor > > The EMPTY_* constants in the IoBuffer class can be made mutable (by using the > setAutoExpand(true) method call) which can result in those constant buffers > no longer being empty. This can obviously cause a multitude of data errors. > See this JUnit test case for an example: > import junit.framework.TestCase; > import org.apache.mina.core.buffer.IoBuffer; > public class TestIoBuffer extends TestCase { > public void testIoBufferAllocate() { > IoBuffer buf = IoBuffer.allocate(0).setAutoExpand(true); > buf.putInt(1234); > buf.flip(); > buf = IoBuffer.allocate(0); > assertEquals(0, buf.remaining()); > } > public void testEmptyIoBuffer() { > IoBuffer buf = IoBuffer.EMPTY_BUFFER.setAutoExpand(true); > buf.putInt(1234); > buf.flip(); > buf = IoBuffer.EMPTY_BUFFER; > assertEquals(0, buf.remaining()); > } > } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.