[Demonstration 1]

[Buggy Method]
public boolean destinationReached(DcMotor motor, double maxPower, double minPower, int distance, double flatness, int marginOfError, int timeoutms) {
    int start;
    ElapsedTime timer;
    if (!startingPos.containsKey(motor.getDeviceName())) {
        start = motor.getCurrentPosition();
        startingPos.put(motor.getDeviceName(), start);
        timer = new ElapsedTime();
        timer.reset();
        startTimer.put(motor.getDeviceName(), timer);
    } else {
        start = startingPos.get(motor.getDeviceName());
        timer = startTimer.get(motor.getDeviceName());
    }
    int error = distance - (motor.getCurrentPosition() - start);
    if (Math.abs(error) > Math.abs(distance)) {
        error = (int) Math.signum(error) * Math.abs(distance);
    }
    if (timer.milliseconds() > timeoutms) {
        startingPos.remove(motor.getDeviceName());
        startTimer.remove(motor.getDeviceName());
        motor.setPower(0);
        return true;
    }
    if (Math.abs(error) < Math.abs(marginOfError)) {
        motor.setPower(0);
    } else {
        // y = a(x-h)^n + k
        // a = (y-k)/(x-h)^n
        // power = y
        // x = error
        // k = maxPower
        // h = distance
        // a = (minPower-maxPower)/(0-distance)^flatness
        distance -= Math.signum(distance) * marginOfError;
        double power = Math.pow(Math.abs(error - distance), flatness);
        power *= -Math.abs(minPower - maxPower) / Math.pow(-distance, flatness);
        power += Math.abs(maxPower);
        power *= Math.signum(error);
        motor.setPower(power);
    }
    return false;
}

[Buggy Hunk]
power *= -Math.abs(minPower - maxPower) / Math.pow(-distance, flatness);

[Patch]
power *= -Math.abs(minPower - maxPower) / Math.pow(-Math.abs(distance), flatness);

[Demonstration 2]

[Buggy Method]
public void driveMotor() {
    motor.set(Constants.INDEXER_POWER);
}

[Buggy Hunk]
motor.set(Constants.INDEXER_POWER);

[Patch]
motor.set(-Constants.INDEXER_POWER);

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