[Demonstration 1]

[Buggy Method]
private void startFsyncThread() {
    final Thread fsyncThread = new Thread() {

        @Override
        public void run() {
            while (true) {
                ObjectOutputStream stream = null;
                try {
                    stream = new ObjectOutputStream(new FileOutputStream(FSYNC_FILENAME));
                    stream.writeObject(mMessages.getNodes());
                    Thread.sleep(30000);
                } catch (Exception e) {
                    System.out.println(e);
                } finally {
                    try {
                        stream.close();
                    } catch (Exception e) {
                        // No big deal!
                    }
                }
            }
        }
    };
    fsyncThread.start();
}

[Buggy Hunk]
stream.writeObject(mMessages.getNodes());

[Patch]
stream.writeObject(mMessages.getValues());

[Demonstration 2]

[Buggy Method]
@Override
public void start() {
    final DatagramSocket udpSocket = packetProvider.getUdpSocket();
    sendThread = new Thread(packetProvider.getIdentifier() + " Sending Thread") {

        @Override
        public void run() {
            long lastFrameSent = System.currentTimeMillis();
            while (!udpSocket.isClosed() && !sendThread.isInterrupted()) {
                try {
                    boolean changeTalking = (System.currentTimeMillis() - lastFrameSent) > OPUS_FRAME_TIME_AMOUNT;
                    DatagramPacket packet = packetProvider.getNextPacket(changeTalking);
                    if (packet != null)
                        udpSocket.send(packet);
                } catch (NoRouteToHostException e) {
                    packetProvider.onConnectionLost();
                } catch (SocketException e) {
                    //Most likely the socket has been closed due to the audio connection be closed. Next iteration will kill loop.
                } catch (Exception e) {
                    AudioConnection.LOG.log(e);
                } finally {
                    long sleepTime = (OPUS_FRAME_TIME_AMOUNT) - (System.currentTimeMillis() - lastFrameSent);
                    if (sleepTime > 0) {
                        try {
                            Thread.sleep(sleepTime);
                        } catch (InterruptedException e) {
                            //We've been asked to stop.
                            Thread.currentThread().interrupt();
                        }
                    }
                    if (// If the sending didn't took longer than 60ms (3 times the time frame)
                    System.currentTimeMillis() < lastFrameSent + 60) {
                        // increase lastFrameSent
                        lastFrameSent += OPUS_FRAME_TIME_AMOUNT;
                    } else {
                        // else reset lastFrameSent to current time
                        lastFrameSent = System.currentTimeMillis();
                    }
                }
            }
        }
    };
    sendThread.setPriority((Thread.NORM_PRIORITY + Thread.MAX_PRIORITY) / 2);
    sendThread.setDaemon(true);
    sendThread.start();
}

[Buggy Hunk]
sendThread = new Thread(packetProvider.getIdentifier() + " Sending Thread")

[Patch]
sendThread = new Thread(ConnectionManager.AUDIO_THREADS, packetProvider.getIdentifier() + " Sending Thread")

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