[Demonstration 1]

[Buggy Method]
public void run() {
    InputStream c1In = null;
    BroadCast broadCast = null;
    try {
        c1In = connected.getSocket().getInputStream();
        DataInputStream dis = new DataInputStream(c1In);
        String newmess = new String(dis.readUTF());
        if (newmess.contains("JPUB")) {
            server.publicRoom.getListClient().add(connected);
            connected.setInRoom(server.publicRoom);
            System.out.printf(connected.getSocket().getPort() + " connected to public room");
            broadCast = new BroadCast(server.publicRoom.getListMessage(), server.publicRoom);
            broadCast.start();
            new SerClient(connected, broadCast).start();
        } else if (newmess.contains("JPRIV")) {
            String passCode = newmess.split(" ")[1];
            for (Room room : server.privateListRoom) {
                if (room.getPasscode() == passCode) {
                    room.addClient(room.getListClient(), connected);
                    connected.setInRoom(room);
                    broadCast = new BroadCast(room.getListMessage(), room);
                    broadCast.start();
                    new SerClient(connected, broadCast).start();
                    break;
                }
            }
            System.out.printf(connected.getSocket().getPort() + " connected to private room");
        } else if (newmess.contains("CREATE")) {
            String passCode = newmess.split(" ")[1];
            Room newRoom = new Room(passCode, new LinkedList<Client>(), new LinkedList<Message>());
            newRoom.addClient(newRoom.getListClient(), connected);
            server.privateListRoom.add(newRoom);
            connected.setInRoom(newRoom);
            broadCast = new BroadCast(newRoom.getListMessage(), newRoom);
            broadCast.start();
            new SerClient(connected, broadCast).start();
            System.out.printf(connected.getSocket().getPort() + " create a private room");
        }
        //            this.stop();
    } catch (IOException ex) {
        Logger.getLogger(FilterClientToRoom.class.getName()).log(Level.SEVERE, null, ex);
    }
}

[Buggy Hunk]
if (room.getPasscode() == passCode) {

[Patch]
if (room.getPasscode().equals(passCode)) {

[Demonstration 2]

[Buggy Method]
@DELETE
@Path("{id}")
public Response deleteUser(@PathParam("id") long userId, @Context HttpServletRequest httpServletRequest) {
    final HttpSession httpSession = httpServletRequest.getSession(false);
    if (httpSession != null) {
        //noinspection SynchronizationOnLocalVariableOrMethodParameter
        synchronized (httpSession) {
            try {
                final Object userIdFromSession = httpSession.getAttribute("user_id");
                if (userIdFromSession == null || !(userIdFromSession instanceof Long)) {
                    return Response.status(Response.Status.NOT_FOUND).entity(new BaseApiResponse()).build();
                }
                if (userId == (long) userId) {
                    userProfileService.deleteUser(userId);
                    authenticationService.deletePasswordForUser(userId);
                    httpSession.invalidate();
                    return Response.ok(new BaseApiResponse()).build();
                }
            } catch (IllegalStateException ignored) {
            }
        }
    }
    return Response.status(Response.Status.FORBIDDEN).entity(new BaseApiResponse()).build();
}

[Buggy Hunk]
if (userId == (long) userId) {

[Patch]
if (userId == (long) userIdFromSession) {

[Demonstration 3]

[Buggy Method]
public int usePotion(String potionName, Mortal target) {
    return useItem(potionName, "Potion", target);
}

[Buggy Hunk]
public int usePotion(String potionName, Mortal target) {

[Patch]
public boolean usePotion(String potionName, Mortal target) {