[Demonstration 1]

[Buggy Method]
@Override
public void commit() throws RollbackException, IllegalStateException {
    if (log.isDebugEnabled()) {
        log.debug("Committing transaction '%s'.", getTransactionInfo());
    }
    if (status == Status.STATUS_NO_TRANSACTION) {
        exceptionThrower.throwException(new IllegalStateException("Can not commit '" + getTransactionInfo() + "'. Transaction has not been started."));
    }
    if (isDoneOrFinishing()) {
        exceptionThrower.throwException(new IllegalStateException("Can not commit '" + getTransactionInfo() + "' with status '" + status + "''. Transaction is finishing or finished."));
    }
    try {
        fireBeforeCompletionEvent();
    } catch (RuntimeException e) {
        rollback();
        exceptionThrower.throwException(new RollbackExceptionImpl("Can not commit '" + getTransactionInfo() + "'. Before completion event firing failed.", e));
    }
    if (status == Status.STATUS_MARKED_ROLLBACK) {
        rollback();
        exceptionThrower.throwException(new RollbackExceptionImpl("Can not commit '" + getTransactionInfo() + "'. Transaction was marked as to be rolled back."));
    } else if (isTimedOut()) {
        rollback();
        exceptionThrower.throwException(new RollbackExceptionImpl("Can not commit '" + getTransactionInfo() + "'. Transaction has timed out."));
    }
    if (beforeCommitValidationRequired()) {
        XAResource xaResource = null;
        try {
            for (XAResource tmpXaResource : getSortedXaResource(xaResources)) {
                xaResource = tmpXaResource;
                if (xaResource instanceof ValidatableResource) {
                    if (!((ValidatableResource) xaResource).isValid()) {
                        throw new IllegalStateException("Resource " + xaResource + " is not valid anymore.");
                    }
                }
            }
        } catch (Throwable t) {
            rollback();
            exceptionThrower.throwException(new RollbackExceptionImpl("Can not commit '" + getTransactionInfo() + "'. Invalid xaResource found: " + xaResource.toString()));
        }
    }
    try {
        setStatus(Status.STATUS_COMMITTING);
        Exception ex = null;
        int idx = 0;
        for (XAResource xaResource : getSortedXaResource(xaResources)) {
            try {
                xaResource.commit(null, true);
            } catch (Exception e) {
                ex = e;
                break;
            }
            idx++;
        }
        if (ex != null) {
            if (idx > 0) {
                getTransactionManagerStatistics().markHeuristicCommit();
            }
            rollback();
            if (idx == 0) {
                exceptionThrower.throwException(new RollbackExceptionImpl("Can not commit '" + getTransactionInfo() + "'. Commiting a resource failed.", ex));
            }
            exceptionThrower.throwException(new HeuristicMixedExceptionImpl("Can not commit '" + getTransactionInfo() + "'. Commiting a resource failed.", ex));
        }
        setStatus(Status.STATUS_COMMITTED);
        notAbandoned = true;
        getTransactionManagerStatistics().markCommitted(suspended);
        if (log.isDebugEnabled()) {
            log.debug("Transaction '%s' successfully commited.", getTransactionInfo());
        }
    } finally {
        fireAfterCompletionEvent();
        xaResources.clear();
        resources.clear();
    }
}

[Buggy Hunk]
exceptionThrower.throwException(new RollbackExceptionImpl("Can not commit '" + getTransactionInfo() + "'. Invalid xaResource found: " + xaResource.toString() ));

[Patch]
exceptionThrower.throwException(new RollbackExceptionImpl("Can not commit '" + getTransactionInfo() + "'." + (xaResource == null ? "" : " Invalid xaResource found: " + xaResource.toString())));

[Demonstration 2]

[Buggy Method]
@Override
public SerenityPublisher newInstance(StaplerRequest req, JSONObject json) throws FormException {
    logger.debug("newInstance");
    SerenityPublisher instance = req.bindParameters(SerenityPublisher.class, "serenity.");
    return instance;
}

[Buggy Hunk]
logger.debug("newInstance");

[Patch]
LOGGER.info("newInstance");

[Demonstration 3]

[Buggy Method]
public HttpResponse doNext(StaplerRequest req) throws FormException, ServletException, IOException {
    //Deprecated function StructureForm.get()
    //JSONObject param = StructuredForm.get(req);
    JSONObject param = req.getSubmittedForm();
    Date ddate = getDefaultDateObject(), now = new Date();
    if (param.containsKey("date")) {
        try {
            ddate = dateFormat().parse(param.getString("date"));
        } catch (ParseException ex) {
            return HttpResponses.redirectTo("error");
        }
    }
    // 120 sec security margin
    quietperiod = ddate.getTime() - now.getTime() + ScheduleBuildAction.securityMargin;
    if (quietperiod < 0) {
        return HttpResponses.redirectTo("error");
    }
    return HttpResponses.forwardToView(this, "redirect");
}

[Buggy Hunk]
public HttpResponse doNext(StaplerRequest req) throws FormException, ServletException, IOException {

[Patch]
public HttpResponse doNext(final StaplerRequest req) throws FormException, ServletException, IOException {