[Demonstration 1]

[Buggy Method]
public static File getDefaultTmpPath(String propName) throws IOException {
    String blurHomeDir = getBlurHomeDir();
    File tmp;
    if (blurHomeDir == null) {
        tmp = getTmpDir();
        LOG.info("Attempting to use default tmp directory [{0}]", tmp);
    } else {
        tmp = new File(blurHomeDir, "tmp");
        LOG.info("Attempting to use configured tmp directory [{0}]", tmp);
        if (!tmp.mkdirs()) {
            tmp = getTmpDir();
            LOG.info("Attempting to use default tmp directory [{0}]", tmp);
        }
    }
    if (!tmp.exists() && !tmp.mkdirs()) {
        throw new IOException("Cannot create tmp directory [" + tmp.toURI() + "], please create directory or configure property [" + propName + "].");
    }
    File file = new File(tmp, UUID.randomUUID().toString());
    if (!file.createNewFile()) {
        throw new IOException("Cannot create tmp file in [" + tmp.toURI() + "].");
    }
    file.delete();
    return tmp;
}

[Buggy Hunk]
if (!tmp.mkdirs()) {

[Patch]
if (!tmp.exists() && !tmp.mkdirs()) {

[Demonstration 2]

[Buggy Method]
private void submitToCatalog(ScheduledExecutorService batchScheduler, ExecutorService executorService, ArrayBlockingQueue<Metacard> metacardQueue, CatalogFacade catalog, long start) {
    batchScheduler.scheduleWithFixedDelay(() -> {
        int queueSize = metacardQueue.size();
        if (queueSize > 0) {
            ArrayList<Metacard> metacardBatch = new ArrayList<>(batchSize);
            // When the producer has finished populating the queue, it will countdown
            // the phaser. The remaining count in the phaser will be metacardCount + main thread
            if (queueSize > batchSize || queueSize == phaser.getRegisteredParties() - 1) {
                metacardQueue.drainTo(metacardBatch, batchSize);
            }
            if (!metacardBatch.isEmpty()) {
                executorService.submit(() -> {
                    try {
                        processBatch(catalog, metacardBatch);
                    } catch (SourceUnavailableException e) {
                        INGEST_LOGGER.warn("Error on process batch.", e);
                    }
                });
                printProgressAndFlush(start, fileCount.get(), ingestCount.get() + ignoreCount.get());
            }
        }
    }, 100, 100, TimeUnit.MILLISECONDS);
}

[Buggy Hunk]
if (queueSize > batchSize || queueSize == phaser.getRegisteredParties() - 1) {

[Patch]
if (queueSize >= batchSize || queueSize == phaser.getRegisteredParties() - 1) {

[Demonstration 3]

[Buggy Method]
public static void handleError(File file, String errorDirectory) throws OpenAS2Exception {
    File destFile = null;
    try {
        File errorDir = IOUtilOld.getDirectoryFile(errorDirectory);
        destFile = new File(errorDir, file.getName());
        // move the file
        destFile = IOUtilOld.moveFile(file, destFile, false, true);
    } catch (IOException ioe) {
        InvalidMessageException im = new InvalidMessageException("Failed to move " + file.getAbsolutePath() + " to error directory " + destFile.getAbsolutePath());
        im.initCause(ioe);
        throw im;
    }
    // make sure an error of this event is logged
    InvalidMessageException imMoved = new InvalidMessageException("Moved " + file.getAbsolutePath() + " to " + destFile.getAbsolutePath());
    imMoved.terminate();
}

[Buggy Hunk]
file.getAbsolutePath() + " to error directory " + destFile.getAbsolutePath());

[Patch]
file.getAbsolutePath() + " to error directory " + ((destFile == null) ? "" : destFile.getAbsolutePath()));