[Demonstration 1]

[Buggy Method]
private ResultSummary executeSoapuiProject(final Path projectPath, final List<String> command) throws MultiTestRunnerException {
    if (Files.isRegularFile(projectPath)) {
        try {
            List<String> runnerCommand = new ArrayList<>(command);
            runnerCommand.add(projectPath.normalize().toString());
            // Add properties according to the place & naming conventions
            addPropertiesIfNecessary(projectPath, runnerCommand, PROPERTY_TYPE.SYSTEM);
            addPropertiesIfNecessary(projectPath, runnerCommand, PROPERTY_TYPE.GLOBAL);
            addPropertiesIfNecessary(projectPath, runnerCommand, PROPERTY_TYPE.PROJECT);
            final ProcessResult processResult = new ProcessExecutor().destroyOnExit().command(runnerCommand).redirectOutput(System.out).readOutput(true).execute();
            final ResultSummary rs = ResultSummary.build(processResult.outputString());
            rs.updateExitCode(processResult.getExitValue());
            return rs;
        } catch (InvalidExitValueException | IOException | InterruptedException | TimeoutException | NumberFormatException | ProcessBuilderException e) {
            final String errMsg = "Error while running " + projectPath.getFileName();
            LOGGER.error(MULTI_TEST_RUNNER_TAG + " " + errMsg);
            throw new MultiTestRunnerException(errMsg, e);
        }
    } else {
        final String errMsg = MULTI_TEST_RUNNER_TAG + " " + projectPath.getFileName() + "is not file.";
        LOGGER.error(errMsg);
        throw new MultiTestRunnerException(errMsg);
    }
}

[Buggy Hunk]
if (Files.isRegularFile(projectPath)) {

[Patch]
if (projectPath.toFile().isFile()) {

[Demonstration 2]

[Buggy Method]
@Override
public String execute(@SuppressWarnings("rawtypes") Map parameters, String body, RenderContext renderContext) throws MacroException {
    // retrieve a reference to the body object this macro is in
    if (!(renderContext instanceof PageContext)) {
        throw new MacroException("This macro can only be used in a page");
    }
    SpaceContentEntityObject page = (SpaceContentEntityObject) ((PageContext) renderContext).getEntity();
    Metadata metadata;
    try {
        metadata = metadataManager.extractMetadata(page);
        if (metadata == null) {
            //macros cannot return null
            return "";
        }
    } catch (MetadataException e) {
        throw new MacroException("Cannot extract Wordpress metadata", e);
    }
    User user;
    if (ServletActionContext.getRequest().getRemoteUser() == null) {
        user = AuthenticatedUserThreadLocal.getUser();
    } else {
        user = page.getUserAccessor().getUser(ServletActionContext.getRequest().getRemoteUser());
    }
    boolean checkUsagePermission = pluginPermissionsManager.checkUsagePermission(user, page);
    return velocityHelper.generateMetadataHtml(page, checkUsagePermission, metadata);
}

[Buggy Hunk]
SpaceContentEntityObject page = (SpaceContentEntityObject) ((PageContext) renderContext).getEntity();

[Patch]
ContentEntityObject page = ((PageContext) renderContext).getEntity();

[Demonstration 3]

[Buggy Method]
private static void checkDatasetProperties(@Nonnull DatasetMetadata metadata) throws MetadataException {
    try {
        Preconditions.checkNotNull(metadata.getThemes(), "Metadata dcat:theme must not be null.");
        Preconditions.checkArgument(!metadata.getThemes().isEmpty(), "Metadata dcat:theme must not be empty.");
    } catch (NullPointerException | IllegalArgumentException ex) {
        String errMsg = ex.getMessage();
        throw (new MetadataException(errMsg));
    }
}

[Buggy Hunk]
throw (new MetadataException(errMsg));

[Patch]
throw new MetadataException(errMsg);