You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Sergei Ivanov (JIRA)" <ji...@apache.org> on 2011/05/31 18:34:47 UTC

[jira] [Commented] (DIRMINA-836) AbstractIoBuffer.putUnsignedXXX(int index, xxx value) methods disregard index

    [ https://issues.apache.org/jira/browse/DIRMINA-836?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13041659#comment-13041659 ] 

Sergei Ivanov commented on DIRMINA-836:
---------------------------------------

Also, a minor thing:
putUnsignedInt(long) should append 'L' to the bit mask constant: 
        buf().putInt( (int)(value&0x00000000ffffffffL) );


> 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