[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]
@Override
public void trainOnInstanceImpl(Instance inst) {
    Instance rinst = inst.copy();
    // Update the FS evaluator (no selection is applied here)
    if (fsmethodOption.getValue() != 0) {
        if (fselector == null) {
            if (fsmethodOption.getValue() == 3) {
                fselector = new OFSGDAttributeEval(numFeaturesOption.getValue());
            } else if (fsmethodOption.getValue() == 2 || fsmethodOption.getValue() == 1) {
                fselector = new IncrInfoThAttributeEval(fsmethodOption.getValue());
            } else {
                //fselector = null;
            }
        }
        try {
            if (inst == null) {
                System.err.println("Error: null instance");
            }
            fselector.updateEvaluator(inst);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    // Update the discretization scheme, and apply it to the given instance
    if (discmethodOption.getValue() != 0) {
        if (discretizer == null) {
            if (discmethodOption.getValue() == 1) {
                discretizer = new PIDdiscretize();
            } else if (discmethodOption.getValue() == 2) {
                discretizer = new IFFDdiscretize();
            } else if (discmethodOption.getValue() == 3) {
                discretizer = new OCdiscretize(this.numClassesOption.getValue());
            } else if (discmethodOption.getValue() == 4) {
                discretizer = new IDAdiscretize();
            } else {
                discretizer = new REBdiscretize();
            }
        }
        if (discmethodOption.getValue() != 5)
            discretizer.updateEvaluator(inst);
        else
            // REBdiscretize needs to know the error rate before removing instances
            ((REBdiscretize) discretizer).updateEvaluator(inst, 1 - ((float) correctlyClassified / classified));
        System.out.println("Number of new intervals: " + discretizer.getNumberIntervals());
        rinst = discretizer.applyDiscretization(inst);
    }
    this.observedClassDistribution.addToValue((int) rinst.classValue(), rinst.weight());
    for (int i = 0; i < rinst.numAttributes() - 1; i++) {
        int instAttIndex = modelAttIndexToInstanceAttIndex(i, rinst);
        AttributeClassObserver obs = this.attributeObservers.get(i);
        com.yahoo.labs.samoa.instances.Attribute att = rinst.attribute(instAttIndex);
        if (obs == null || (att.isNominal() && obs instanceof NumericAttributeClassObserver)) {
            obs = att.isNominal() ? newNominalClassObserver() : newNumericClassObserver();
            this.attributeObservers.set(i, obs);
        }
        // Problem with spam assasin
        double value = rinst.value(instAttIndex);
        if (rinst.value(instAttIndex) == -1) {
            System.out.println("Value changed");
            value = 0;
        }
        obs.observeAttributeClass(value, (int) rinst.classValue(), rinst.weight());
    }
    totalCount++;
}

[Buggy Hunk]
discretizer = new REBdiscretize();

[Patch]
discretizer = new REBdiscretize(winSizeOption.getValue(), thresholdOption.getValue());

[Demonstration 3]

[Buggy Method]
String findElement(int element) {
    String string = "";
    boolean inArray = false;
    for (int i = 0; i < array.length; i++) {
        if (array[i] == element) {
            if (inArray)
                string += ", ";
            string += i + 1;
            inArray = true;
        }
    }
    if (string.equals(""))
        return ("NOWHERE\n");
    return string;
}

[Buggy Hunk]
string += i + 1;

[Patch]
string += (i+1);