[Demonstration 1]

[Buggy Method]
public void init() {
    // can't call this in the constructor because it relies on the implemented interfaces for callbacks
    if (!JNIIbdxnet.init(m_coreConfig.getOwnNodeId(), (int) m_config.getIncomingBufferSize().getBytes(), (int) m_config.getOugoingRingBufferSize().getBytes(), m_config.getIncomingBufferPoolTotalSize().getBytes(), m_config.getMaxRecvReqs(), m_config.getMaxSendReqs(), m_config.getFlowControlMaxRecvReqs(), m_config.getMaxConnections(), this, this, this, this, m_config.getEnableSignalHandler(), m_config.getEnableDebugThread())) {
        // #if LOGGER >= DEBUG
        LOGGER.debug("Initializing ibnet failed, check ibnet logs");
        // #endif /* LOGGER >= DEBUG */
        throw new NetworkRuntimeException("Initializing ibnet failed");
    }
    // this is an ugly way of figuring out which nodes are available on startup. the ib subsystem needs that kind of information to
    // contact the nodes using an ethernet connection to exchange ib connection information
    // if you know a better/faster way of doing this here, be my guest and fix it
    for (int i = 0; i < NodeID.MAX_ID; i++) {
        if (i == (m_coreConfig.getOwnNodeId() & 0xFFFF)) {
            continue;
        }
        InetSocketAddress addr = m_nodeMap.getAddress((short) i);
        if (!"/255.255.255.255".equals(addr.getAddress().toString())) {
            byte[] bytes = addr.getAddress().getAddress();
            int val = (int) (((long) bytes[0] & 0xFF) << 24 | bytes[1] & 0xFF << 16 | bytes[2] & 0xFF << 8 | bytes[3] & 0xFF);
            JNIIbdxnet.addNode(val);
        }
    }
}

[Buggy Hunk]
int val = (int) (((long) bytes[0] & 0xFF) << 24 | bytes[1] & 0xFF << 16 | bytes[2] & 0xFF << 8 | bytes[3] & 0xFF);

[Patch]
int val = (int) (((long) bytes[0] & 0xFF) << 24 | ((long) bytes[1] & 0xFF) << 16 | ((long) bytes[2] & 0xFF) << 8 | bytes[3] & 0xFF);

[Demonstration 2]

[Buggy Method]
public int getGangRating() {
    int rating = 0;
    for (Ganger g : gangers) {
        rating += g.getCost() + g.getExp();
    }
    return rating;
}

[Buggy Hunk]
rating += g.getCost() + g.getExp();

[Patch]
rating += g.getCost() + g.getExp() + g.getEquipmentCost();

[Demonstration 3]

[Buggy Method]
public synchronized String read() {
    byte[] messageFirsTwoBytes = new byte[2];
    input.mark(100000);
    int extraLength = 0;
    byte[] length = new byte[0];
    try {
        input.read(messageFirsTwoBytes, 0, 2);
        if ((messageFirsTwoBytes[0] & 0xFF) == 0b10001000) {
            connection = false;
            this.close();
            return "[Connection Closed]";
        }
        int contentLength = 0;
        if (((int) messageFirsTwoBytes[1] & 0b01111111) <= 125)
            contentLength = (int) (messageFirsTwoBytes[1] & 0b01111111);
        if ((messageFirsTwoBytes[1] & 0b01111111) == 126) {
            length = new byte[2];
            extraLength = 2;
            input.read(length, 0, 2);
            contentLength = ((length[0] & 0xff) << 8) | (length[1] & 0xff);
        }
        if (messageFirsTwoBytes[1] == 127) {
            length = new byte[8];
            extraLength = 8;
            input.read(length, 0, 8);
            contentLength = ((length[0] & 0xff) << 56) | ((length[1] & 0xff) << 48 | (length[2] & 0xff) << 40 | (length[3] & 0xff) << 32 | (length[4] & 0xff) << 24 | (length[5] & 0xff) << 16 | (length[6] & 0xff) << 8 | (length[7] & 0xff));
        }
        byte[] content = new byte[contentLength + 4];
        input.read(content, 0, contentLength + 4);
        byte[] wholeMessage = new byte[2 + extraLength + contentLength + 4];
        int i = 0;
        for (int j = 0; j < 2; j++, i++) {
            wholeMessage[i] = messageFirsTwoBytes[j];
        }
        for (int j = 0; j < extraLength; j++, i++) {
            wholeMessage[i] = length[j];
        }
        for (int j = 0; j < contentLength + 4; j++, i++) {
            wholeMessage[i] = content[j];
        }
        return decodeMessage(wholeMessage);
    } catch (IOException e) {
        e.printStackTrace();
    }
    return "";
}

[Buggy Hunk]
return decodeMessage(wholeMessage);

[Patch]
return decodeMessage(wholeMessage, contentLength);