[Demonstration 1]

[Buggy Method]
public List<Constraintx> getConstraints(RefOntoUML.Element element) {
    List<Constraintx> result = new ArrayList<Constraintx>();
    for (Constraintx obj : getAllInstances(RefOntoUML.Constraintx.class)) {
        if (obj.getConstrainedElement().equals(element))
            result.add(obj);
    }
    return result;
}

[Buggy Hunk]
if(obj.getConstrainedElement().equals(element)) result.add(obj);

[Patch]
if(((RefOntoUML.Classifier)element).getOwnedRule().contains(obj)) result.add(obj);

[Demonstration 2]

[Buggy Method]
public void generate(Object obj) throws Exception {
    if (this.coercions != null) {
        IFn fn;
        while ((fn = (IFn) coercions.get(obj.getClass())) != null) {
            obj = fn.invoke(obj);
        }
    }
    if (obj instanceof String) {
        jg.writeString((String) obj);
    } else if (obj instanceof Number) {
        if (obj instanceof Integer) {
            jg.writeNumber((Integer) obj);
        } else if (obj instanceof Long) {
            jg.writeNumber((Long) obj);
        } else if (obj instanceof BigInteger) {
            jg.writeNumber((BigInteger) obj);
        } else if (obj instanceof Double) {
            jg.writeNumber((Double) obj);
        } else if (obj instanceof Float) {
            jg.writeNumber((Float) obj);
        }
    } else if (obj instanceof Boolean) {
        jg.writeBoolean((Boolean) obj);
    } else if (obj == null) {
        jg.writeNull();
    } else if (obj instanceof Keyword) {
        jg.writeString(((Keyword) obj).getName());
    } else if (obj instanceof IPersistentMap) {
        IPersistentMap map = (IPersistentMap) obj;
        ISeq mSeq = map.seq();
        jg.writeStartObject();
        while (mSeq != null) {
            IMapEntry me = (IMapEntry) mSeq.first();
            Object key = me.key();
            if (key instanceof Keyword) {
                jg.writeFieldName(((Keyword) key).getName());
            } else if (key instanceof Integer) {
                jg.writeFieldName(((Integer) key).toString());
            } else if (key instanceof BigInteger) {
                jg.writeFieldName(((BigInteger) key).toString());
            } else if (key instanceof Long) {
                jg.writeFieldName(((Long) key).toString());
            } else {
                jg.writeFieldName((String) key);
            }
            generate(me.val());
            mSeq = mSeq.next();
        }
        jg.writeEndObject();
    } else if (obj instanceof Iterable) {
        jg.writeStartArray();
        for (Object o : (Iterable) obj) {
            generate(o);
        }
        jg.writeEndArray();
    } else {
        throw new Exception("Cannot generate " + obj);
    }
}

[Buggy Hunk]
if (this.coercions != null) {

[Patch]
if (this.coercions != null && obj != null) {

[Demonstration 3]

[Buggy Method]
public static Result service(String ownerName, String projectName, String service, boolean isAdvertise) throws IOException, UnsupportedOperationException, ServletException {
    if (!isSupportedService(service)) {
        return forbidden(String.format("Unsupported service: '%s'", service));
    }
    Project project = Project.findByOwnerAndProjectName(ownerName, projectName);
    if (project == null) {
        return notFound();
    }
    models.User user = UserApp.currentUser();
    if (!isAllowed(project, service)) {
        if (user.isAnonymous()) {
            return BasicAuthAction.unauthorized(response());
        } else {
            // If you want the Git client showing your custom message to
            // the user, the Content-Type should be exact "text/plain"
            // without any parameter. For more details, see the code at
            // https://github.com/git/git/commit/426e70d4a11ce3b4f70636d57c6a0ab16ae08a00#diff-eea0ad565ec5903a11b6023755d491cfR154
            response().setHeader("Content-Type", "text/plain");
            return forbidden(String.format("'%s' has no permission to '%s/%s'.", user.name, ownerName, projectName));
        }
    }
    if (isAdvertise) {
        return ok(RepositoryService.gitAdvertise(project, service, response()));
    } else {
        if (request().body().isMaxSizeExceeded()) {
            return status(REQUEST_ENTITY_TOO_LARGE);
        } else {
            user.visits(project);
            return ok(RepositoryService.gitRpc(project, service, request(), response()));
        }
    }
}

[Buggy Hunk]
user.name, ownerName, projectName));

[Patch]
user.loginId, ownerName, projectName));