[Demonstration 1]

[Buggy Method]
@Test
public void testLockResponseInvariants() {
    LockResponse permDeny = new LockResponse(Status.DENIED_PERMANENT, new LockInfo());
    assertFalse(permDeny.isOk());
    LockResponse denied = LockResponse.DENIED(new LockInfo());
    assertFalse(denied.isOk());
    LockResponse error = LockResponse.ERROR;
    assertFalse(error.isOk());
    LockResponse ok = LockResponse.OK();
    assertTrue(ok.isOk());
}

[Buggy Hunk]
LockResponse ok = LockResponse.OK();

[Patch]
LockResponse ok = LockResponse.OK(null);

[Demonstration 2]

[Buggy Method]
@SuppressWarnings("ObjectEquality")
public int compareTo(int offset, int length, Slice that, int otherOffset, int otherLength) {
    if ((this == that) && (offset == otherOffset) && (length == otherLength)) {
        return 0;
    }
    checkIndexLength(offset, length);
    that.checkIndexLength(otherOffset, otherLength);
    int compareLength = Math.min(length, otherLength);
    while (compareLength >= SIZE_OF_LONG) {
        long thisLong = unsafe.getLong(base, address + offset);
        thisLong = Long.reverseBytes(thisLong);
        long thatLong = unsafe.getLong(that.base, that.address + otherOffset);
        thatLong = Long.reverseBytes(thatLong);
        int v = compareUnsignedLongs(thisLong, thatLong);
        if (v != 0) {
            return v;
        }
        offset += SIZE_OF_LONG;
        otherOffset += SIZE_OF_LONG;
        compareLength -= SIZE_OF_LONG;
    }
    while (compareLength > 0) {
        byte thisByte = unsafe.getByte(base, address + offset);
        byte thatByte = unsafe.getByte(that.base, that.address + otherOffset);
        int v = compareUnsignedBytes(thisByte, thatByte);
        if (v != 0) {
            return v;
        }
        offset++;
        otherOffset++;
        compareLength--;
    }
    return Integer.compare(length, otherLength);
}

[Buggy Hunk]
return Integer.compare(length, otherLength);

[Patch]
return Integer.valueOf(length).compareTo(Integer.valueOf(otherLength));

[Demonstration 3]

[Buggy Method]
@Test
public void testFlush() {
    Context context = new Context("k1", "v1");
    ContextList contexts = new ContextList();
    contexts.addContext(context);
    for (int i = 0; i < 1000; i++) {
        client.increment(contexts, "key1");
        client.increment(contexts, "key2", 100l);
    }
    client.flush();
    try {
        Thread.sleep(60);
    } catch (InterruptedException ie) {
    }
    assertTrue(client.getContextStats().isEmpty());
}

[Buggy Hunk]
assertTrue(client.getContextStats().isEmpty());

[Patch]
assertEquals(1000l, client.getContextStats().get(contexts).get("key1"));