[Demonstration 1]

[Buggy Method]
private void showPicture() {
    if (!mPictureFile.exists()) {
        return;
    }
    BitmapFactory.Options option = new BitmapFactory.Options();
    option.inJustDecodeBounds = true;
    BitmapFactory.decodeFile(mPictureFile.getAbsolutePath(), option);
    option.inSampleSize = CameraUtil.calculateInSampleSize(option, mPictureIv.getMeasuredWidth(), mPictureIv.getMeasuredHeight());
    option.inJustDecodeBounds = false;
    mPictureIv.setImageBitmap(BitmapFactory.decodeFile(mPictureFile.getAbsolutePath(), option));
    //        try {
    ////            MediaStore.Images.Media.insertImage(getContentResolver(), mPictureFile.getAbsolutePath(), "ExCamera", null);
    //        } catch (FileNotFoundException e) {
    //            e.printStackTrace();
    //        }
    Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE, Uri.parse("file://" + mPictureFile.getAbsolutePath()));
    sendBroadcast(intent);
}

[Buggy Hunk]
if (!mPictureFile.exists()) {

[Patch]
if (mPictureFile == null || !mPictureFile.exists()) {

[Demonstration 2]

[Buggy Method]
@Override
public void run() {
    runner.setAutoRestartNiFi(false);
    final int ccPort = runner.getNiFiCommandControlPort();
    if (ccPort > 0) {
        System.out.println("Initiating Shutdown of NiFi...");
        try {
            final Socket socket = new Socket("localhost", ccPort);
            final OutputStream out = socket.getOutputStream();
            out.write("SHUTDOWN\n".getBytes(StandardCharsets.UTF_8));
            out.flush();
            socket.close();
        } catch (final IOException ioe) {
            System.out.println("Failed to Shutdown NiFi due to " + ioe);
        }
    }
    System.out.println("Waiting for Apache NiFi to finish shutting down...");
    final long startWait = System.nanoTime();
    while (RunNiFi.isAlive(nifiProcess)) {
        final long waitNanos = System.nanoTime() - startWait;
        final long waitSeconds = TimeUnit.NANOSECONDS.toSeconds(waitNanos);
        if (waitSeconds >= gracefulShutdownSeconds && gracefulShutdownSeconds > 0) {
            if (RunNiFi.isAlive(nifiProcess)) {
                System.out.println("NiFi has not finished shutting down after " + gracefulShutdownSeconds + " seconds. Killing process.");
                nifiProcess.destroy();
            }
            break;
        } else {
            try {
                Thread.sleep(1000L);
            } catch (final InterruptedException ie) {
            }
        }
    }
    final File statusFile = runner.getStatusFile();
    if (!statusFile.delete()) {
        System.err.println("Failed to delete status file " + statusFile.getAbsolutePath() + "; this file should be cleaned up manually");
    }
}

[Buggy Hunk]
out.write("SHUTDOWN\n".getBytes(StandardCharsets.UTF_8));

[Patch]
out.write(("SHUTDOWN " + secretKey + "\n").getBytes(StandardCharsets.UTF_8));

[Demonstration 3]

[Buggy Method]
public List<Airport> findAll() {
    return entityManager.createNamedQuery(Airport.FIND_ALL, Airport.class).getResultList();
}

[Buggy Hunk]
return entityManager.createNamedQuery(Airport.FIND_ALL, Airport.class).getResultList();

[Patch]
return entityManager.createNamedQuery(Airport.FIND_ALL_ACTIVE, Airport.class).getResultList();