[Demonstration 1]

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

[Demonstration 2]

[Buggy Method]
private OrderDO persistOrder(Order order) {
    OrderDO orderDO = new OrderDO();
    order.setOrderType(order.getOrderType());
    Product product = order.getProduct();
    if (null == product) {
        //this should have a product id
        String productID = order.getProductID();
        if (null == productID) {
            throw new BadRequestException("No product or product id");
        }
        //check if this id exists
        ProductDO p = ProductDAO.getProductDOByID(productID);
        if (null == p) {
            throw new BadRequestException("Product with id {" + productID + "} does not exist");
        }
        orderDO.setProductID(productID);
        product = transform(p);
    } else {
        ProductDO productDO = new ProductDO();
        productDO.setCompany(product.getCompany());
        productDO.setGenericName(product.getGenericName());
        productDO.setName(product.getName());
        store.save(productDO);
        product.setId(productDO.getId());
        orderDO.setProductID(productDO.getId());
    }
    Batch batch = order.getBatch();
    if (null == batch) {
        //this should have a batch id
        String batchID = order.getBatchID();
        if (null == batchID) {
            throw new BadRequestException("No batch or batch id");
        }
        //check if this id exists
        BatchDO b = BatchDAO.getBatchDOByID(batchID);
        if (null == b) {
            throw new BadRequestException("Batch with id {" + batchID + "} does not exist");
        }
        orderDO.setBatchID(batchID);
        //batch = transform(b); - not needed
    } else {
        BatchDO batchDO = new BatchDO();
        batchDO.setProductID(product.getId());
        batchDO.setCode(batch.getCode());
        batchDO.setExpDate(batch.getExpDate());
        batchDO.setMfgDate(batch.getMfgDate());
        batchDO.setPack(batch.getPack());
        store.save(batchDO);
        batch.setId(batchDO.getId());
        orderDO.setBatchID(batchDO.getId());
    }
    orderDO.setPrice(order.getPrice());
    orderDO.setCgst(order.getCgst());
    orderDO.setSgst(order.getSgst());
    orderDO.setQuantity(order.getQuantity());
    orderDO.setTotalCost(order.getTotalCost());
    store.save(orderDO);
    return orderDO;
}

[Buggy Hunk]
order.setOrderType(order.getOrderType());

[Patch]
orderDO.setOrderType(order.getOrderType());

[Demonstration 3]

[Buggy Method]
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    if (request.getSession().getAttribute("orderId") == null) {
        request.setAttribute("message", "You dont have order to cancel");
        request.getRequestDispatcher("/taxi/menuauthorized.jsp").forward(request, response);
    } else {
        long orderId = Long.parseLong((String) request.getSession().getAttribute("orderId"));
        DBConnection dbConnection = new DBConnection();
        OrderDAO orderDAO = new OrderDAOImpl(dbConnection.getConnection(), dbConnection.getDatabaseName());
        try {
            Order order = orderDAO.getById(orderId);
            order.setTaxiId((long) 0);
            order.setOrderStatus(Order.OrderStatus.WAITING);
            orderDAO.update(order);
            request.getSession().setAttribute("orderId", null);
            request.setAttribute("message", "Canceled order Id=" + orderId);
            request.getRequestDispatcher("/taxi/menuauthorized.jsp").forward(request, response);
        } catch (SQLException e) {
            e.printStackTrace();
            request.getRequestDispatcher("/taxi").forward(request, response);
        }
    }
}

[Buggy Hunk]
request.getSession().setAttribute("orderId", null);

[Patch]
request.getSession().removeAttribute("orderId");