[Demonstration 1]

[Buggy Method]
private void decrementConcurrency() {
    checkState(inProgress, "is in progress");
    inProgress = false;
    synchronized (concurrentAttempts) {
        Integer uriConcurrent = concurrentAttempts.get(uri);
        if (uriConcurrent == null || uriConcurrent <= 1) {
            concurrentAttempts.remove(uri);
            if (concurrentAttempts.isEmpty()) {
                concurrency.update(0);
            }
        } else {
            concurrentAttempts.put(uri, uriConcurrent - 1);
            if (concurrency.get() == uriConcurrent) {
                for (Integer concurrent : concurrentAttempts.values()) {
                    if (concurrent == uriConcurrent) {
                        ++uriConcurrent;
                        break;
                    }
                }
                concurrency.update(uriConcurrent - 1);
            }
        }
    }
}

[Buggy Hunk]
if (concurrent == uriConcurrent) {

[Patch]
if (uriConcurrent.equals(concurrent)) {

[Demonstration 2]

[Buggy Method]
@Test
public void assertNeverAtMatchingPredicate() {
    TestSubscriber<Integer> ts = new TestSubscriber<>();
    Flowable.just(1, 2).subscribe(ts);
    thrown.expect(AssertionError.class);
    ts.assertNever(new Predicate<Integer>() {

        @Override
        public boolean test(final Integer o) throws Exception {
            return o == 1;
        }
    });
}

[Buggy Hunk]
TestSubscriber<Integer> ts = new TestSubscriber<>();

[Patch]
TestSubscriber<Integer> ts = new TestSubscriber<Integer>();

[Demonstration 3]

[Buggy Method]
public void testFileUpload() throws Exception {
    final String filename = "MyFile.txt";
    final File file = new File("/sdcard/" + filename);
    if (!file.exists()) {
        file.createNewFile();
        final OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(file));
        out.write("This is a test!");
        out.close();
    }
    assertTrue("File should exist", file.exists());
    final RestResponse response = restClient.uploadFile(file, filename, "Test Title", "Test Description");
    assertNotNull("Response should not be null", response);
    assertEquals("Status code should be 201 CREATED", HttpStatus.SC_CREATED, response.getStatusCode());
    file.delete();
    assertFalse("File should not exist", file.exists());
}

[Buggy Hunk]
final File file = new File("/sdcard/" + filename);

[Patch]
final File file = new File(Environment.getExternalStorageDirectory() + File.separator + filename);