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

AbstractIoBuffer.putUnsignedXXX(int index, xxx value) methods disregard index

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.0.3
    • 2.0.4
    • Core
    • None

    Description

      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.

      Attachments

        Activity

          People

            vrm Julien Vermillard
            sergei_ivanov Sergei Ivanov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: