[Demonstration 1]

[Buggy Method]
public static Send getSender(String senderClassName) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
    if (senderClassName == null || senderClassName.isEmpty()) {
        throw new NullPointerException("The senderClassName cannot be empty");
    }
    Class<?> sendClass = Class.forName(senderClassName);
    Send send = (Send) sendClass.newInstance();
    return send;
}

[Buggy Hunk]
throw new NullPointerException("The senderClassName cannot be empty");

[Patch]
throw new ClassNotFoundException("The senderClassName cannot be empty");

[Demonstration 2]

[Buggy Method]
@Test
public void testPostSplitIn() throws UnsupportedEncodingException {
    String reqText = "POST /form HTTP/1.1\r\n" + "Host: localhost:8888\r\n" + "Connection: keep-alive\r\n" + "Content-Length: 28\r\n" + "Origin: http://localhost:8888\r\n" + "Content-Type: application/x-www-form-urlencoded\r\n" + "Referer: http://localhost:8888/form\r\n" + "Accept-Encoding: gzip, deflate\r\n" + "Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4\r\n" + "\r\n" + "firstname=J.&lastnam";
    ByteBuffer buffer = ByteBuffer.wrap(reqText.getBytes("ascii"));
    HttpRequestDecoder decoder = new HttpRequestDecoder();
    ByteBuffer body = ByteBuffer.allocate(1024);
    HttpRequestDecoder.Result result = decoder.decode(buffer, body, false);
    assertTrue(result.isHeaderCompleted());
    assertFalse(result.getResponse().isPresent());
    assertTrue(decoder.getHeader().get().messageHasBody());
    assertEquals("POST", decoder.getHeader().get().getMethod());
    assertEquals("/form", decoder.getHeader().get().getRequestUri().getPath());
    assertFalse(result.isOverflow());
    assertTrue(result.isUnderflow());
    assertTrue(!buffer.hasRemaining());
    // Rest
    buffer = ByteBuffer.wrap("e=Grapes".getBytes("ascii"));
    result = decoder.decode(buffer, body, false);
    assertFalse(result.isHeaderCompleted());
    assertFalse(result.getResponse().isPresent());
    assertFalse(result.isOverflow());
    assertFalse(result.isUnderflow());
    assertTrue(!buffer.hasRemaining());
    body.flip();
    String bodyText = new String(body.array(), body.position(), body.limit());
    assertEquals("firstname=J.&lastname=Grapes", bodyText);
}

[Buggy Hunk]
assertTrue(!buffer.hasRemaining());

[Patch]
assertFalse(buffer.hasRemaining());

[Demonstration 3]

[Buggy Method]
public void putImage(String name, ByteBuffer bitmap) {
    try {
        mImageCache.putBitmap(name, bitmap);
    } catch (NullPointerException e) {
        throw new IllegalStateException("Disk Cache Not initialized");
    }
}

[Buggy Hunk]
throw new IllegalStateException("Disk Cache Not initialized");

[Patch]
VinciLog.e("Put Image failed, name cannot be null", e);