[Demonstration 1]

[Buggy Method]
public static OMElement getResourceDocumentElement(File resourceFile) throws XMLStreamException, IOException {
    OMElement resourceElement;
    FileInputStream fis = null;
    XMLStreamReader reader = null;
    try {
        fis = FileUtils.openInputStream(resourceFile);
        reader = xif.createXMLStreamReader(fis);
        StAXOMBuilder builder = new StAXOMBuilder(reader);
        resourceElement = builder.getDocumentElement();
        resourceElement.detach();
    } catch (XMLStreamException e) {
        throw new XMLStreamException(e.getMessage(), e);
    } catch (IOException e) {
        throw new IOException(e.getMessage(), e);
    } finally {
        try {
            if (fis != null) {
                fis.close();
            }
        } catch (IOException e) {
            log.error(e.getMessage(), e);
        }
        try {
            if (reader != null) {
                reader.close();
            }
        } catch (XMLStreamException e) {
            log.error(e.getMessage(), e);
        }
    }
    return resourceElement;
}

[Buggy Hunk]
reader = xif.createXMLStreamReader(fis);

[Patch]
reader = xmlInputFactory.createXMLStreamReader(fis);

[Demonstration 2]

[Buggy Method]
@RequestMapping("/login.html")
public ModelAndView login(HttpServletRequest request, @RequestParam(value = "source", required = false) String source, @RequestParam(value = "openid", required = false) String openid) throws Exception {
    ModelAndView mav = null;
    if (source == null) {
        mav = new ModelAndView(StringUtil.getUserAgentViewName(request, "user/login"));
        mav.addObject("openid", openid);
    } else if ("wechat".equals(source)) {
        String redirectURI = String.format("%s%s/wechat_callback.html", getURLBase(request), request.getContextPath());
        String redirectURL = String.format("https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s&redirect_uri=%s&response_type=code&scope=snsapi_base&state=wechat#wechat_redirect", WechatService.CORP_ID, redirectURI);
        logger.info(String.format("Redirecting to %s", redirectURL));
        mav = new ModelAndView("redirect:" + redirectURL);
    }
    return mav;
}

[Buggy Hunk]
mav.addObject("openid", openid);

[Patch]
if(openid!=null) mav.addObject("openid", openid);

[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));