[Demonstration 1]

[Buggy Method]
private static int delete(File f) {
    int deleted = 0;
    boolean dir = false;
    if (f.isDirectory()) {
        dir = true;
        for (File g : f.listFiles()) {
            deleted += delete(g);
        }
        Log.i(TAG, "cleaned directory file " + f);
    }
    if (f.delete()) {
        if (!f.isDirectory())
            if (!dir)
                deleted++;
        Log.i(TAG, "deleted file " + f);
    } else {
        Log.e(TAG, "failed to delete file! " + f);
    }
    return deleted;
}

[Buggy Hunk]
for(File g: f.listFiles()) {

[Patch]
for(File g: listFilesSafe(f)) {

[Demonstration 2]

[Buggy Method]
@Override
public void sendMessage(RespT message) {
    Preconditions.checkState(!closeCalled, "call is closed");
    sendMessageCalled = true;
    try {
        InputStream resp = method.streamResponse(message);
        stream.writeMessage(resp);
        if (!inOnReady) {
            stream.flush();
        }
    } catch (Throwable t) {
        close(Status.fromThrowable(t), new Metadata());
        throw Throwables.propagate(t);
    }
}

[Buggy Hunk]
if (!inOnReady) {

[Patch]
if (onReadyThreadId == -1 || onReadyThreadId != Thread.currentThread().getId()) {

[Demonstration 3]

[Buggy Method]
@Test
public void subtractionTest() {
    AppResource appResource = new AppResource();
    assertThat(appResource.add(15, 5)).isEqualTo(10);
}

[Buggy Hunk]
assertThat(appResource.add(15, 5)).isEqualTo(10);

[Patch]
assertThat(appResource.subtrract(15, 5)).isEqualTo(10);