mirror of
https://github.com/corda/corda.git
synced 2025-06-19 23:53:52 +00:00
Fixed an off-by-one error when deciding if we should grow BitSets.
This commit is contained in:
@ -105,9 +105,9 @@ public class BitSet implements Serializable, Cloneable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void enlarge(int newSize) {
|
private void enlarge(int newPartition) {
|
||||||
if (bits == null || bits.length < newSize) {
|
if (bits == null || bits.length < (newPartition + 1)) {
|
||||||
long[] newBits = new long[newSize + 1];
|
long[] newBits = new long[newPartition + 1];
|
||||||
if (bits != null) {
|
if (bits != null) {
|
||||||
System.arraycopy(bits, 0, newBits, 0, bits.length);
|
System.arraycopy(bits, 0, newBits, 0, bits.length);
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,10 @@ public class BitsetTest {
|
|||||||
assertEquals("after 100, 102 is empty", 102, bits.nextClearBit(100));
|
assertEquals("after 100, 102 is empty", 102, bits.nextClearBit(100));
|
||||||
|
|
||||||
testFlip();
|
testFlip();
|
||||||
|
|
||||||
|
BitSet expandingSet = new BitSet();
|
||||||
|
//should force us to have 3 partitions.
|
||||||
|
expandingSet.set(128);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void testFlip() {
|
private static void testFlip() {
|
||||||
|
Reference in New Issue
Block a user