AbstractIoBuffer.putUnsignedXXX(int index, xxx value) methods disregard index
-----------------------------------------------------------------------------
Key: DIRMINA-836
URL: https://issues.apache.org/jira/browse/DIRMINA-836
Project: MINA
Issue Type: Bug
Components: Core
Affects Versions: 2.0.3
Reporter: Sergei Ivanov
Relates to DIRMINA-823, where these methods were first introduced.
All the "indexed" putUnsignedXXX() methods disregard the index when writing to
the underlying buffer.
For example:
public final IoBuffer putUnsignedInt(int index, byte value) {
autoExpand(index, 4);
buf().putInt( (int)((short)value&0x00ff) );
// --------------- ^^^^ --- should pass 'index' in as the first parameter
return this;
}
The test cases in Mina core, attached to revision 1090588, do not catch this
because although they use indexed puts, they use unindexed gets (had they used
symmetrical indexed gets, they would have failed). A code snippet that
demonstrates the problem is below:
final IoBuffer buffer = IoBuffer.allocate(128);
buffer.putUnsignedInt(10, 0x87654321L);
buffer.putUnsignedInt(20, 0xFFFFFFFFL);
System.out.printf("buffer.getUnsignedInt(0) = 0x%08X\n",
buffer.getUnsignedInt(0));
System.out.printf("buffer.getUnsignedInt(4) = 0x%08X\n",
buffer.getUnsignedInt(4));
System.out.printf("buffer.getUnsignedInt(10) = 0x%08X\n",
buffer.getUnsignedInt(10));
System.out.printf("buffer.getUnsignedInt(20) = 0x%08X\n",
buffer.getUnsignedInt(20));
A trivial fix is required, which is to pass 'index' parameter to buf().putInt()
or buf().putShort() method call.
--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira