[Demonstration 1]

[Buggy Method]
public HerokuJson getHerokuJson(String clientId) {
    try {
        log.debug("start getDerivativeJson");
        //            Client client = clientService.findById(clientId, 4);
        //            client.getLegalEntities().stream().forEach(le ->{shortName = le.getShortName();le.getClientSignsRelations().stream().map(csr -> csr.getAgreement()).
        //                    filter(agreement -> agreement.getMarginStatements() != null).forEach(agreement -> handleAgreement(agreement));});
        Iterable<MarginStatement> marginStatementIterable = marginStatementService.allStatementsForClient(clientId);
        StreamSupport.stream(marginStatementIterable.spliterator(), false).forEach(this::handleStatement);
    } catch (Exception e) {
        log.error("error in getDerivativeJson", e);
    }
    return builder.getJson();
}

[Buggy Hunk]
log.debug("start getDerivativeJson");

[Patch]
log.info("start getDerivativeJson");

[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]
@Override
public void start(Future<Void> startFuture) throws Exception {
    // fist we need operational parameters, either from
    // environment or from vertx configuration file
    String rabbitHost = System.getenv("RABBIT_HOST");
    if (rabbitHost == null) {
        rabbitHost = config().getString("rabbit.host", DEFAULT_RABBIT_HOST);
    }
    logger.info("Using rabbit host " + rabbitHost);
    Integer rabbitPort = Integer.getInteger("RABBIT_PORT");
    if (rabbitPort == null) {
        rabbitPort = config().getInteger("rabbit.port", DEFAULT_RABBIT_PORT);
    }
    logger.info("Using rabbit port " + rabbitPort);
    Integer httpPort = Integer.getInteger("HTTP_PORT");
    if (httpPort == null) {
        httpPort = config().getInteger("http.port", DEFAULT_HTTP_PORT);
    }
    logger.info("Using http port " + httpPort);
    // a rabbitMQ client is needed
    rabbitMQClient = RabbitMQClient.create(vertx, new JsonObject().put("host", rabbitHost).put("port", rabbitPort));
    rabbitMQClient.start(startResult -> {
        if (startResult.succeeded()) {
            logger.info("RabbitMQ client has been started");
            rabbitMQClient.exchangeDeclare(EXCHANGE_NAME, "direct", false, true, exchangeDeclarationResult -> {
                if (exchangeDeclarationResult.failed()) {
                    logger.error("Can't declare the '" + EXCHANGE_NAME + "' exchange", exchangeDeclarationResult.cause());
                    startFuture.fail(exchangeDeclarationResult.toString());
                } else {
                    logger.info("Exchange '" + EXCHANGE_NAME + "' has been declared");
                }
            });
        } else {
            logger.error("RabbitMQ client couldn't start", startResult.cause());
            startFuture.fail(startResult.toString());
        }
    });
    // create the routes that are recognised by the service
    // and send requests to appropriate handler/catalog
    Router router = Router.router(vertx);
    // allow CORS, so that we can use swagger (and other tools) for testing
    Set<HttpMethod> allowedMethods = new HashSet<>();
    allowedMethods.add(GET);
    allowedMethods.add(PUT);
    allowedMethods.add(POST);
    Set<String> allowedHeaders = new HashSet<>();
    allowedHeaders.add("x-requested-with");
    allowedHeaders.add("Access-Control-Allow-Origin");
    allowedHeaders.add("origin");
    allowedHeaders.add("Content-Type");
    allowedHeaders.add("accept");
    router.route().handler(CorsHandler.create("*").allowedMethods(allowedMethods).allowedHeaders(allowedHeaders));
    router.route(GET, "/subscriptions/:id").handler(this::handleGetSubscription);
    router.route(PUT, "/subscriptions/:id").handler(this::handlePutSubscription);
    router.route(POST, "/messages").handler(this::handlePostMessage);
    // finally, create the http server, using the created router
    vertx.createHttpServer().requestHandler(router::accept).listen(httpPort, result -> {
        if (result.succeeded()) {
            logger.info("Messaging server started");
            startFuture.complete();
        } else {
            logger.error("Couldn't start messaging server", result.cause());
            startFuture.fail(result.cause());
        }
    });
}

[Buggy Hunk]
rabbitMQClient.exchangeDeclare(EXCHANGE_NAME, "direct", false, true, exchangeDeclarationResult -> {

[Patch]
rabbitMQClient.exchangeDeclare(EXCHANGE_NAME, "direct", true, false, exchangeDeclarationResult -> {