[Demonstration 1]

[Buggy Method]
@Override
public void afterCommit() {
    schema.setObjectId(object, element);
}

[Buggy Hunk]
schema.setObjectId(object, element);

[Patch]
schema.setObjectId(object, createdElement);

[Demonstration 2]

[Buggy Method]
public static Optional<? extends ConceptChronology<? extends ConceptVersion<?>>> getConceptForUnknownIdentifier(String identifier) {
    LOG.debug("WB DB String Lookup '{}'", identifier);
    if (StringUtils.isBlank(identifier)) {
        return Optional.empty();
    }
    String localIdentifier = identifier.trim();
    UUID uuid = Utility.getUUID(localIdentifier);
    if (uuid != null) {
        return Get.conceptService().getOptionalConcept(uuid);
    }
    //if it is a negative integer, assume nid
    Optional<Integer> nid = Utility.getNID(localIdentifier);
    if (nid.isPresent()) {
        return Get.conceptService().getOptionalConcept(nid.get());
    }
    if (SctId.isValidSctId(localIdentifier)) {
        SememeIndexer si = LookupService.get().getService(SememeIndexer.class);
        if (si != null) {
            //force the prefix algorithm, and add a trailing space - quickest way to do an exact-match type of search
            List<SearchResult> result = si.query(localIdentifier + " ", true, IsaacMetadataAuxiliaryBinding.SNOMED_INTEGER_ID.getConceptSequence(), 5, Long.MIN_VALUE);
            if (result.size() > 0) {
                int componentNid = Get.sememeService().getSememe(result.get(0).getNid()).getReferencedComponentNid();
                if (Get.identifierService().getChronologyTypeForNid(componentNid) == ObjectChronologyType.CONCEPT) {
                    return Get.conceptService().getOptionalConcept();
                } else {
                    LOG.warn("Passed in SCTID is not a Concept ID!");
                    return Optional.empty();
                }
            }
        } else {
            LOG.warn("Sememe Index not available - can't lookup SCTID");
        }
    } else if (Utility.isInt(localIdentifier)) {
        //Must be a postive integer, which wasn't a valid SCTID - it may be a sequence ID.
        int nidFromSequence = Get.identifierService().getConceptNid(Integer.parseInt(localIdentifier));
        if (nidFromSequence != 0) {
            return Get.conceptService().getOptionalConcept(nidFromSequence);
        }
    }
    return Optional.empty();
}

[Buggy Hunk]
return Get.conceptService().getOptionalConcept();

[Patch]
return Get.conceptService().getOptionalConcept(componentNid);

[Demonstration 3]

[Buggy Method]
@Override
public void doFilter(ServletRequest req, ServletResponse resp, FilterChain chain) throws IOException, ServletException {
    RequestLogAccessor rla;
    try {
        rla = new RequestLogAccessor();
    } catch (SQLException e) {
        throw new RuntimeException("request logger creation failed", e);
    }
    HttpServletRequest hr = (HttpServletRequest) req;
    String uri = hr.getPathInfo(), json = null;
    Date start = new Date();
    if (req.getContentType().equals("application/json")) {
        ServletInputStream s = req.getInputStream();
        json = IOUtils.toString(s);
        final String body = json;
        req = new HttpServletRequestWrapper((HttpServletRequest) req) {

            public ServletInputStream getInputStream() throws IOException {
                return new ServletInputStream() {

                    InputStream in_ = IOUtils.toInputStream(body);

                    @Override
                    public int read() throws IOException {
                        return in_.read();
                    }
                };
            }
        };
    }
    if (json != null)
        chain.doFilter(req, resp);
    Date end = new Date();
    try {
        rla.logRequest(end.getTime() - start.getTime(), uri, json);
    } catch (SQLException e) {
        e.printStackTrace(System.err);
    }
}

[Buggy Hunk]
if(req.getContentType().equals("application/json")) {

[Patch]
if(req.getContentType() != null && req.getContentType().equals("application/json")) {