public static int compareToWithAckSet(Position currentPosition, Position otherPosition) {
        if (currentPosition == null || otherPosition == null) {
            throw new IllegalArgumentException("Two positions can't be null! "
                    + "current position : [" + currentPosition + "] other position : [" + otherPosition + "]");
        }
        int result = currentPosition.compareTo(otherPosition);
        if (result == 0) {
            BitSetRecyclable otherAckSet;
            BitSetRecyclable currentAckSet;

            long[] otherAckSetArr = AckSetStateUtil.getAckSetArrayOrNull(otherPosition);
            if (otherAckSetArr == null) {
                otherAckSet = BitSetRecyclable.create();
            } else {
                otherAckSet = BitSetRecyclable.valueOf(otherAckSetArr);
            }

            long[] currentAckSetArr = AckSetStateUtil.getAckSetArrayOrNull(currentPosition);
            if (currentAckSetArr == null) {
                currentAckSet = BitSetRecyclable.create();
            } else {
                currentAckSet = BitSetRecyclable.valueOf(currentAckSetArr);
            }

            if (currentAckSet.isEmpty() || otherAckSet.isEmpty()) {
                //when ack set is empty, the nextSetBit will return -1, so we should return the inverse value.
                result = -(currentAckSet.nextSetBit(0) - otherAckSet.nextSetBit(0));
            } else {
                result = currentAckSet.nextSetBit(0) - otherAckSet.nextSetBit(0);
            }
            currentAckSet.recycle();
            otherAckSet.recycle();
        }
        return result;
    }
@Test
    public void compareToWithAckSetForCumulativeAckTest() {
        Position positionOne = PositionFactory.create(1, 1);
        Position positionTwo = PositionFactory.create(1, 2);
        assertEquals(compareToWithAckSet(positionOne, positionTwo), -1);
        positionTwo = PositionFactory.create(2, 1);
        assertEquals(compareToWithAckSet(positionOne, positionTwo), -1);
        positionTwo = PositionFactory.create(0, 1);
        assertEquals(compareToWithAckSet(positionOne, positionTwo), 1);
        positionTwo = PositionFactory.create(1, 0);
        assertEquals(compareToWithAckSet(positionOne, positionTwo), 1);
        positionTwo = PositionFactory.create(1, 1);
        assertEquals(compareToWithAckSet(positionOne, positionTwo), 0);

        BitSet bitSetOne = new BitSet();
        BitSet bitSetTwo = new BitSet();
        bitSetOne.set(0, 63);
        bitSetTwo.set(0, 63);
        bitSetOne.clear(0, 10);
        bitSetTwo.clear(0, 10);
        positionOne = AckSetStateUtil.createPositionWithAckSet(1, 1, bitSetOne.toLongArray());
        positionTwo = AckSetStateUtil.createPositionWithAckSet(1, 1, bitSetTwo.toLongArray());
        assertEquals(compareToWithAckSet(positionOne, positionTwo), 0);

        bitSetOne.clear(10, 12);
        AckSetState positionOneAckSetState = AckSetStateUtil.getAckSetState(positionOne);
        positionOneAckSetState.setAckSet(bitSetOne.toLongArray());
        assertEquals(compareToWithAckSet(positionOne, positionTwo), 2);

        bitSetOne.set(8, 12);
        positionOneAckSetState.setAckSet(bitSetOne.toLongArray());
        assertEquals(compareToWithAckSet(positionOne, positionTwo), -2);
    }