[Demonstration 1]

[Buggy Method]
private List<Double> calculateMeans(List<Object> singleClass) {
    List<Double> means = new ArrayList<>();
    int noFeature = singleClass.get(0).getFeaturesNumber();
    for (int index = 0; index < noFeature; index++) {
        double sum = 0.0;
        for (Object object : singleClass) {
            sum += object.getFeatures().get(index);
        }
        means.add(sum / (double) noFeature);
    }
    return means;
}

[Buggy Hunk]
means.add(sum / (double) noFeature);

[Patch]
means.add(sum / (double) singleClass.size());

[Demonstration 2]

[Buggy Method]
@Override
public void run() {
    while (true) {
        receive(a.removeMessage());
    }
}

[Buggy Hunk]
while (true){

[Patch]
while (!this.isInterrupted()){

[Demonstration 3]

[Buggy Method]
public boolean doEvents(long timeout) {
    int keySize;
    try {
        keySize = timeout == 0 ? selector.selectNow() : timeout < 0 ? selector.select() : selector.select(timeout);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    if (keySize == 0) {
        invokeQueue();
        return false;
    }
    Set<SelectionKey> selectedKeys = selector.selectedKeys();
    for (SelectionKey key : selectedKeys) {
        if (!key.isValid()) {
            continue;
        }
        if (key.isAcceptable()) {
            Server server = (Server) key.attachment();
            SocketChannel socketChannel;
            try {
                socketChannel = server.serverSocketChannel.accept();
                if (socketChannel == null) {
                    continue;
                }
                socketChannel.configureBlocking(false);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            Client client = new Client(this, server.serverConnection.get());
            client.socketChannel = socketChannel;
            add(client, SelectionKey.OP_READ);
            client.finishConnect();
            continue;
        }
        Client client = (Client) key.attachment();
        try {
            if (key.isReadable()) {
                int bytesRead = client.socketChannel.read(ByteBuffer.wrap(buffer, 0, client.bufferSize));
                if (bytesRead > 0) {
                    client.connection.onRecv(buffer, 0, bytesRead);
                    // may be closed by "onRecv"
                    if (!key.isValid()) {
                        continue;
                    }
                } else if (bytesRead < 0) {
                    client.startClose();
                    // Disconnected, so skip onSend and onConnect
                    continue;
                }
            }
            // may be both isReadable() and isWritable() ?
            if (key.isWritable()) {
                client.write();
            } else if (key.isConnectable() && client.socketChannel.finishConnect()) {
                client.finishConnect();
                // "onConnect()" might call "disconnect()"
                if (client.isOpen() && client.isBusy()) {
                    client.write();
                }
            }
        } catch (IOException e) {
            client.startClose();
        }
    }
    selectedKeys.clear();
    invokeQueue();
    return true;
}

[Buggy Hunk]
add(client, SelectionKey.OP_READ);

[Patch]
client.add(selector, SelectionKey.OP_READ);