[Demonstration 1]

[Buggy Method]
String sendRequest(String commandline) throws IOException {
    ByteBuffer writeBuffer = wrapCommandToBuffer(commandline);
    while (writeBuffer.hasRemaining()) {
        clientSocket.write(writeBuffer);
    }
    ByteBuffer readBuffer = ByteBuffer.allocate(1024);
    if (clientSocket.read(readBuffer) == -1) {
        throw new IOException();
    }
    readBuffer.flip();
    return new String(readBuffer.array()).trim();
}

[Buggy Hunk]
String sendRequest(String commandline) throws IOException {

[Patch]
public String sendRequest(String commandline) throws IOException {

[Demonstration 2]

[Buggy Method]
public TemplateList getTemplateList() throws TimeoutException, IOException {
    TemplateList req = new TemplateList();
    connection.sendRequestAndWait(req);
    if (req.getMessageBox() != null) {
        System.out.println(" -- " + req.getMessageBox().getText());
    }
    return req;
}

[Buggy Hunk]
System.out.println(" -- "+req.getMessageBox().getText());

[Patch]
System.out.println(" -- "+req.getMessageBox().getText().toString().replace("\n", ""));

[Demonstration 3]

[Buggy Method]
@Override
public CertificatePair loadAgent(UUID siteId, UUID agentId) {
    try {
        if (this.agentKeyFile(siteId, agentId).exists()) {
            return new CertificatePair(this.agentCrtFile(siteId, agentId), this.agentKeyFile(siteId, agentId));
        } else {
            return new CertificatePair(this.agentCrtFile(siteId, agentId), null);
        }
    } catch (Exception e) {
        throw new RuntimeException("Failed to load certificate for agent: " + siteId + "::" + agentId, e);
    }
}

[Buggy Hunk]
return new CertificatePair(this.agentCrtFile(siteId, agentId), null);

[Patch]
return new CertificatePair(this.agentCrtFile(siteId, agentId));