[Demonstration 1]

[Buggy Method]
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    response.setContentType("text/html");
    JSONObject json = new JSONObject();
    HttpSession session = request.getSession();
    String login = (String) session.getAttribute("login");
    if (login != null) {
        //int score = ((Long) session.getAttribute("score")).intValue();
        String score = (String) session.getAttribute("score");
        try {
            json.put("response", "true");
            json.put("login", login);
            json.put("score", score);
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    } else {
        try {
            json.put("response", "false");
        } catch (JSONException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    PrintWriter out = response.getWriter();
    out.print(json);
    out.flush();
}

[Buggy Hunk]
String score = (String) session.getAttribute("score");

[Patch]
long score = (long) session.getAttribute("score");

[Demonstration 2]

[Buggy Method]
private void approveBook(HttpServletRequest request, HttpServletResponse response, HttpSession session) throws IOException {
    if (session != null && StringUtils.equals((String) session.getAttribute("hasRole"), "librarian")) {
        Long operationId = Long.parseLong(request.getParameter("operationId"));
        bookService.approveBook(operationId);
        if (StringUtils.isNotEmpty(request.getParameter("page"))) {
            int page = Integer.parseInt(request.getParameter("page"));
            response.sendRedirect("index?action=listBooks&page=" + page);
        } else {
            response.sendRedirect("index?action=listBooks");
        }
    } else {
        response.sendRedirect("index?action=listBooks");
    }
}

[Buggy Hunk]
if (session != null && StringUtils.equals((String) session.getAttribute("hasRole"), "librarian")) {

[Patch]
if (session != null && StringUtils.equals((String) session.getAttribute("hasRole"), "librarian") && StringUtils.isNotEmpty(request.getParameter("operationId"))) {

[Demonstration 3]

[Buggy Method]
public double getExchangeRate(LocalDate date, SupportedCurrency currency) {
    return getExchangeRate(date, currency.name());
}

[Buggy Hunk]
public double getExchangeRate(LocalDate date, SupportedCurrency currency) {

[Patch]
public Double getExchangeRate(LocalDate date, SupportedCurrency currency) {