[JAVOLUTION-68] IndexOutOfBoundsException when limit < capacity Created: 31/Mar/10  Updated: 27/Apr/10  Resolved: 27/Apr/10

Status: Resolved
Project: javolution
Component/s: www
Affects Version/s: current
Fix Version/s: milestone 1

Type: Bug Priority: Major
Reporter: johncurrier Assignee: javolution-issues
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Issuezilla Id: 68

 Description   

The following JUnit test case, when run against 5.4.5, throws an
IndexOutOfBoundsException when the buffer's limit is less than its capacity. I
assume the fix is to check for limit instead of capacity in Struct's
readByteBufferLong and readByte methods.

public class IndexPastEndTest
{
class Item8 extends Struct

{ private final Signed8 data = new Signed8(4); }

class Item16 extends Struct

{ private final Signed16 data = new Signed16(4); }

class Item32 extends Struct

{ private final Signed32 data = new Signed32(4); }

/**

  • When limit == capacity it works fine
    */
    @Test
    public void readPastEndWithoutExtraCapacity() { Item32 item = new Item32(); ByteBuffer buf = ByteBuffer.allocate(item.size()); buf.limit(item.size()); item.setByteBuffer(buf, 0); item.data.get(); }

/**

  • When limit < capacity it throws an IndexOutOfBoundsException
    */
    @Test
    public void readPastEndWithExtraCapacity() { Item32 item = new Item32(); ByteBuffer buf = ByteBuffer.allocate(item.size() + 1); buf.limit(item.size()); item.setByteBuffer(buf, 0); item.data.get(); }

/**

  • When limit < capacity it throws an IndexOutOfBoundsException
    */
    @Test
    public void read16PastEndWithExtraCapacity() { Item16 item = new Item16(); ByteBuffer buf = ByteBuffer.allocate(item.size() + 1); buf.limit(item.size()); item.setByteBuffer(buf, 0); item.data.get(); }

/**

  • When limit < capacity it throws an IndexOutOfBoundsException
    */
    @Test
    public void read8PastEndWithExtraCapacity() { Item8 item = new Item8(); ByteBuffer buf = ByteBuffer.allocate(item.size() + 1); buf.limit(item.size()); item.setByteBuffer(buf, 0); item.data.get(); }

    }



 Comments   
Comment by dautelle [ 21/Apr/10 ]

Fixed in 5.5.1

Comment by johncurrier [ 27/Apr/10 ]

Any idea when 5.5.1 will be available? The site says that it came out on April
22nd, but the latest jar available for download is 5.5.0.

Thanks,
John

Generated at Sun Sep 25 16:01:17 UTC 2016 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.