[Demonstration 1]

[Buggy Method]
public void exchangeInformation(final HashKnowledgeMap<Knowledge> other) {
    final HashMap<Point, KnowledgeBucket<Knowledge>> toPutIntoOther = new HashMap<>();
    for (HashMap.Entry<Point, KnowledgeBucket<Knowledge>> mapping : other._map.entrySet()) {
        KnowledgeBucket<Knowledge> ownKnowledge = getKnowledgeBucket(mapping.getKey());
        if (ownKnowledge._lastUpdate < mapping.getValue().getLastUpdate()) {
            _map.put(mapping.getKey(), mapping.getValue());
        } else {
            toPutIntoOther.put(mapping.getKey(), ownKnowledge);
        }
    }
    other._map.putAll(toPutIntoOther);
}

[Buggy Hunk]
for (HashMap.Entry<Point, KnowledgeBucket<Knowledge>> mapping : other._map.entrySet()) {

[Patch]
for (Map.Entry<Point, KnowledgeBucket<Knowledge>> mapping : other._map.entrySet()) {

[Demonstration 2]

[Buggy Method]
@Test
public void getNullValueTest() {
    final Settings settings = new MapSettings();
    final String value = null;
    settings.setProperty(EXAMPLE_KEY, value);
    final SonarManager manager = new SonarManager(settings);
    assertNotNull(manager.getValue(EXAMPLE_KEY));
    assertEquals(manager.getValue(EXAMPLE_KEY), "");
}

[Buggy Hunk]
assertEquals(manager.getValue(EXAMPLE_KEY), "");

[Patch]
assertEquals("", manager.getValue(EXAMPLE_KEY));

[Demonstration 3]

[Buggy Method]
@Test
public void multiple4Mbwrites() throws IOException {
    Assume.assumeTrue(testsEnabled);
    String filename = directory + "/" + "Sdk.multiple4Mbwrites.txt";
    // do three 4mb writes
    ADLFileInfo f = client.getFileInfo(filename);
    byte[] contents = HelperUtils.getRandom4mbBuffer();
    OutputStream out = f.createFromStream(true);
    ByteArrayOutputStream bos = new ByteArrayOutputStream(contents.length * 3);
    for (int i = 0; i < 3; i++) {
        out.write(contents);
        bos.write(contents);
    }
    out.close();
    bos.close();
    byte[] b1 = bos.toByteArray();
    // read file contents
    InputStream in = f.getReadStream();
    // double the size, to account for possible bloat due to bug in upload
    byte[] b2 = new byte[b1.length * 2];
    int bytesRead;
    int count = 0;
    while ((bytesRead = in.read(b2, count, b2.length - count)) >= 0 && count <= b2.length) {
        count += bytesRead;
    }
    // verify what was read is identical to what was written
    assertTrue("file length should match what was written", b1.length == count);
    byte[] b3 = Arrays.copyOfRange(b2, 0, count);
    assertTrue("file contents should match", Arrays.equals(b1, b3));
}

[Buggy Hunk]
Assume.assumeTrue(testsEnabled);

[Patch]
Assume.assumeTrue(false);