[Demonstration 1]

[Buggy Method]
@Override
protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    CallContext context = null;
    try {
        // CSRF token check
        if (!METHOD_GET.equals(request.getMethod()) && !METHOD_HEAD.equals(request.getMethod())) {
            checkCsrfToken(request, response, false, false);
        }
        // split path
        String[] pathFragments = HttpUtils.splitPath(request);
        // create stream factory
        TempStoreOutputStreamFactory streamFactoy = TempStoreOutputStreamFactory.newInstance(getServiceFactory(), pathFragments.length > 0 ? pathFragments[0] : null, request);
        // treat HEAD requests
        if (METHOD_HEAD.equals(request.getMethod())) {
            request = new HEADHttpServletRequestWrapper(request);
            response = new NoBodyHttpServletResponseWrapper(response);
        } else {
            request = new QueryStringHttpServletRequestWrapper(request);
        }
        // set default headers
        response.addHeader("Cache-Control", "private, max-age=0");
        response.addHeader("Server", ServerVersion.OPENCMIS_SERVER);
        context = createContext(getServletContext(), request, response, streamFactoy);
        dispatch(context, request, response, pathFragments);
    } catch (Exception e) {
        if (e instanceof CmisUnauthorizedException) {
            response.setHeader("WWW-Authenticate", "Basic realm=\"CMIS\", charset=\"UTF-8\"");
            response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Authorization Required");
        } else if (e instanceof CmisPermissionDeniedException) {
            if ((context == null) || (context.getUsername() == null)) {
                response.setHeader("WWW-Authenticate", "Basic realm=\"CMIS\", charset=\"UTF-8\"");
                response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Authorization Required");
            } else {
                response.sendError(getErrorCode((CmisPermissionDeniedException) e), e.getMessage());
            }
        } else {
            printError(e, request, response);
        }
    } catch (Throwable t) {
        LOG.error(createLogMessage(t, request), t);
        try {
            response.resetBuffer();
            response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
            response.setContentType(AbstractBrowserServiceCall.JSON_MIME_TYPE);
            response.setCharacterEncoding(IOUtils.UTF8);
            PrintWriter pw = response.getWriter();
            writeHtmlErrorPage(pw, 500, "runtime", "An error occurred!", t);
            pw.flush();
        } catch (Exception te) {
            // we tried to send an error message but it failed.
            // there is nothing we can do...
        }
        throw t;
    } finally {
        // we are done.
        try {
            response.flushBuffer();
        } catch (IOException ioe) {
            LOG.error("Could not flush resposne: {}", ioe.toString(), ioe);
        }
    }
}

[Buggy Hunk]
response.setContentType(AbstractBrowserServiceCall.JSON_MIME_TYPE);

[Patch]
response.setContentType("text/html");

[Demonstration 2]

[Buggy Method]
public String json(DateFormat dateFormat, NumberFormat numberFormater) {
    return "{t='" + dateFormat.format(new Date(this.timestamp)) + "' v=" + numberFormater.format(this.value) + "}";
}

[Buggy Hunk]
return  "{t='"+dateFormat.format(new Date(this.timestamp))+"' v="+numberFormater.format(this.value)+"}";

[Patch]
return  "{t='"+dateFormat.format(new Date(this.timestamp*1000))+"' v="+numberFormater.format(this.value)+"}";

[Demonstration 3]

[Buggy Method]
void addPathToField(String fieldName, HtmlPath path) {
    List<HtmlPath> paths = fields.get(fieldName);
    if (paths == null) {
        paths = new ArrayList<HtmlPath>();
        fields.put(fieldName, paths);
    }
    paths.add(path);
}

[Buggy Hunk]
List<HtmlPath> paths = fields.get(fieldName);

[Patch]
List<HtmlPath> paths = (List<HtmlPath>) fields.get(fieldName);