[Demonstration 1]

[Buggy Method]
@Path("addNote")
@GET
@Produces(MediaType.APPLICATION_JSON)
public Note addNote(@QueryParam("text") String text, @QueryParam("lat") float latitude, @QueryParam("long") float longitude) {
    Note note = new Note();
    note.setText(text);
    note.setLatitude(latitude);
    note.setLongitude(longitude);
    note.persist();
    return note;
}

[Buggy Hunk]
note.persist();

[Patch]
noteRepository.SaveNote(note);

[Demonstration 2]

[Buggy Method]
public void run() {
    System.out.println("Starting ProcessPricing thread for processing the requests");
    // Infinte loop so that it runs indefinitely
    while (!stop) {
        try {
            // Get request from PricingServiceImpl thread
            QueueRequestDB req = requestsToProcess.take();
            System.out.println("Processing request " + req.getToken());
            req.setProcessing(true);
            // Price the request
            AccountPricer pricer = new AccountPricer(req);
            req.setResult(pricer.getAccountData());
            req.setDone(true);
            req.setCompletedTime(System.currentTimeMillis() / 1000L);
            req.setProcessing(false);
            req.setQueuePos(-5);
            System.out.println("Completed pricing request " + req.getToken());
            //Pass the data back to PricingServiceImpl thread
            processedRequests.put(req);
        } catch (InterruptedException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
    }
    System.out.println("ProcessPricing thread stopped.");
}

[Buggy Hunk]
} catch (InterruptedException e1) {

[Patch]
} catch (Exception e1) {

[Demonstration 3]

[Buggy Method]
private static Thread startSocket(int port) {
    Thread t = new Thread() {

        @Override
        public void run() {
            ArrayList<Connection> connections = new ArrayList<Connection>();
            try {
                serverSocket = new ServerSocket(port);
                while (!isInterrupted()) {
                    if (connections.size() < 100) {
                        // ex con
                        Socket socket = serverSocket.accept();
                        System.out.println("New Connection established.");
                        Connection connection = new Connection(socket);
                        connection.start();
                        connections.add(connection);
                    } else {
                        try {
                            System.out.println("Too many open connections. Sleeping for 1000ms");
                            Thread.sleep(1000);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                    }
                }
                serverSocket.close();
            } catch (SocketException e) {
                if (!isInterrupted())
                    e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
            for (Connection c : connections) {
                c.interrupt();
            }
        }
    };
    t.start();
    return t;
}

[Buggy Hunk]
private static Thread startSocket(int port) {

[Patch]
private static Thread startSocket(final int port) {