vnedilko / artemis-framework

Automatically exported from code.google.com/p/artemis-framework
0 stars 0 forks source link

Bag.set always resets Bag.size to the last set item's position #7

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
1. Fill a bag with 10 elements
2. Call bag.set(4, newitem);
3. Check bag.size();

bag.size() should still be 10, since there are 10 elements in it regardless of 
the fact that we just changed the 5th element using set.

bag.size() is instead 5, since the set call incorrectly changed it's size.

This bug has been fixed in a number of artemis ports from what I saw. The fix 
is to surround the size = index+1; statement with if (index >= size) {...}, to 
only change the bag's size if the new item being set is past the current size.

Original issue reported on code.google.com by pete.d...@kimbleoperations.com on 9 Jan 2013 at 1:09