[Demonstration 1]

[Buggy Method]
@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
    String message = new String(body, "UTF-8");
    //对象转JSON串
    Message msg = (Message) JSON.parse(message);
    System.out.println(" [x] Received Object'" + msg.getName() + ", " + msg.getAddress() + "'");
    System.out.println(" [x] Received '" + message + "'");
}

[Buggy Hunk]
Message msg = (Message) JSON.parse(message);

[Patch]
Message msg = JSON.parseObject(message, Message.class);

[Demonstration 2]

[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 3]

[Buggy Method]
public void doCancel(HttpServletRequest request, HttpServletResponse response) {
    logger.info("Cancelling job process");
    try {
        int processId = Integer.parseInt(request.getParameter("id"));
        JobProcessDao jobProcessDao = new JobProcessDao();
        JobProcessStatus jps = jobProcessDao.getJobProcessStatus(processId);
        jps.setCondition(JobProcessStatus.Condition.CANCELLED);
        jps.setCompleted(false);
        jps.setMessages(Arrays.asList("Cancelled by user"));
        int update = jobProcessDao.setJobProcessStatus(jps);
        if (update > 0) {
            setJobResponse(new JobActionResponse(true, "Job " + processId + " has been cancelled."), response);
            return;
        }
    } catch (NumberFormatException ex) {
        logger.warn("Failed to parse job process id for cancellation!");
    }
    setJobResponse(new JobActionResponse(false, "Failed to cancel job process!"), response);
}

[Buggy Hunk]
jps.setMessages(Arrays.asList("Cancelled by user"));

[Patch]
jps.setMessages(Arrays.asList("Cancelled by user",""));