[Demonstration 1]

[Buggy Method]
public void addStation(Station s, Boolean two_way) {
    // We need to build the track if this is adding to existing stations
    if (this.stations.size() > 0) {
        // Get the last station
        Station last = this.stations.get(this.stations.size() - 1);
        // Generate a new track
        Track t;
        if (two_way) {
            t = new DualTrack(last.position, s.position, this.trackColour);
        } else {
            t = new Track(last.position, s.position, this.trackColour);
        }
        this.tracks.add(t);
    }
    // Add the station
    s.registerLine(this);
    this.stations.add(s);
}

[Buggy Hunk]
t = new Track(last.position, s.position, this.trackColour);

[Patch]
t = new SingleTrack(last.position, s.position, this.trackColour);

[Demonstration 2]

[Buggy Method]
@Before
public void setUp() {
    SocialGraph socialGraph = new SocialGraph();
    Tracks2D trackA = new Tracks2D(0, 0);
    trackA.addPointData(new Point2D(1, 1, 1));
    trackA.addPointData(new Point2D(2, 2, 2));
    trackA.addPointData(new Point2D(3, 3, 3));
    Tracks2D trackB = new Tracks2D(1, 0);
    trackB.addPointData(new Point2D(1, 3, 2));
    trackB.addPointData(new Point2D(4, 2, 3));
    trackB.addPointData(new Point2D(5, 3, 4));
    Tracks2D trackC = new Tracks2D(2, 0);
    trackC.addPointData(new Point2D(5, 2, 4));
    trackC.addPointData(new Point2D(2, 26, 5));
    trackC.addPointData(new Point2D(36, 3, 6));
    Tracks2D trackD = new Tracks2D(3, 0);
    trackD.addPointData(new Point2D(54, 24, 4));
    trackD.addPointData(new Point2D(24, 26, 5));
    trackD.addPointData(new Point2D(36, 33, 6));
    Map<Integer, Track> tracks = new HashMap<>();
    tracks.put(0, trackA);
    tracks.put(1, trackB);
    tracks.put(2, trackC);
    tracks.put(3, trackD);
    double[][] adjMatrix = socialGraph.createAdjacencyMatrix(socialGraph.convertToList(tracks));
    modularityMeasure = new ModularityMeasure(tracks);
    List<Double> totalConnectionStrength = socialGraph.calculateTotalConnectionStrength(adjMatrix);
    totalMatrixStrength = socialGraph.calculateTotalMatrixStrength(adjMatrix);
    modularityMatrix = socialGraph.calculateModularityMatrix(adjMatrix, totalConnectionStrength, totalMatrixStrength);
}

[Buggy Hunk]
Map<Integer, Track> tracks = new HashMap<>();

[Patch]
HashMap<Integer, Track> tracks = new HashMap<>();

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