[Demonstration 1]

[Buggy Method]
private static final SearchParameters getSearchParameters(Map<String, Object> parameters) {
    SearchParameters searchParameters = new SearchParameters();
    searchParameters.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
    searchParameters.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO);
    searchParameters.setQuery(getQuery(parameters));
    searchParameters.setSkipCount((int) parameters.get(PARAMETER_SKIP));
    searchParameters.addSort("@" + ContentModel.PROP_MODIFIED, true);
    searchParameters.addSort("@" + ContentModel.PROP_NODE_DBID, true);
    searchParameters.setUseInMemorySort(false);
    searchParameters.setLimitBy(LimitBy.FINAL_SIZE);
    searchParameters.setLimit((int) parameters.get(PARAMETER_LIMIT) + (int) parameters.get(PARAMETER_SKIP));
    return searchParameters;
}

[Buggy Hunk]
searchParameters.setLimit((int) parameters.get(PARAMETER_LIMIT) + (int) parameters.get(PARAMETER_SKIP));

[Patch]
searchParameters.setLimit((int) parameters.get(PARAMETER_LIMIT));

[Demonstration 2]

[Buggy Method]
@Override
public void prepare(WSRequest request, String contentType, URL url) {
    if (request != null) {
        String authorization = IpcContextHolder.get(AUTHORIZATION_HEADER);
        if (authorization != null) {
            request.setHeader(AUTHORIZATION_HEADER, BEARER + " " + authorization);
        } else if (controllerRequest != null) {
            authorization = controllerRequest.getHeader(AUTHORIZATION_HEADER);
            if (authorization != null) {
                request.setHeader(AUTHORIZATION_HEADER, authorization);
            }
        }
    }
}

[Buggy Hunk]
String authorization = IpcContextHolder.get(AUTHORIZATION_HEADER);

[Patch]
String authorization = (String) IpcContextHolder.getContext().get(AUTHORIZATION_HEADER);

[Demonstration 3]

[Buggy Method]
@Override
public void handleGET(CoapExchange exchange) {
    Collection<Resource> resources = rdResource.getChildren();
    List<String> query = exchange.getRequestOptions().getUriQuery();
    String result = "";
    String domainQuery = "";
    String endpointQuery = "";
    TreeSet<String> endpointTypeQuery = new TreeSet<String>();
    for (String q : query) {
        LinkAttribute attr = LinkAttribute.parse(q);
        if (attr.getName().equals(LinkFormat.DOMAIN)) {
            domainQuery = attr.getValue();
        }
        if (attr.getName().equals(LinkFormat.END_POINT)) {
            endpointQuery = attr.getValue();
        }
        if (attr.getName().equals(LinkFormat.END_POINT_TYPE)) {
            Collections.addAll(endpointTypeQuery, attr.getValue().split(" "));
        }
    }
    Iterator<Resource> resIt = resources.iterator();
    while (resIt.hasNext()) {
        Resource res = resIt.next();
        if (res.getClass() == RDNodeResource.class) {
            RDNodeResource node = (RDNodeResource) res;
            if ((domainQuery.isEmpty() || domainQuery.equals(node.getDomain())) && (endpointQuery.isEmpty() || endpointQuery.equals(node.getEndpointIdentifier())) && (endpointTypeQuery.isEmpty() || endpointTypeQuery.contains(node.getEndpointType()))) {
                result += "<" + node.getContext() + ">;" + LinkFormat.END_POINT + "=\"" + node.getEndpointIdentifier() + "\"";
                result += ";" + LinkFormat.DOMAIN + "=\"" + node.getDomain() + "\"";
                if (!node.getEndpointType().isEmpty()) {
                    result += ";" + LinkFormat.RESOURCE_TYPE + "=\"" + node.getEndpointType() + "\"";
                }
                result += ",";
            }
        }
    }
    if (result.isEmpty()) {
        exchange.respond(ResponseCode.NOT_FOUND);
    } else {
        exchange.respond(ResponseCode.CONTENT, result.substring(0, result.length() - 1), MediaTypeRegistry.APPLICATION_LINK_FORMAT);
    }
}

[Buggy Hunk]
if(!node.getEndpointType().isEmpty()){

[Patch]
if(node.getEndpointType() != null && !node.getEndpointType().isEmpty()){ // fixed NullPointerException. was: if(!node.getEndpointType().isEmpty()){