[Demonstration 1]

[Buggy Method]
private void encodeAndPad(ByteBuffer buf, double d) {
    long dBits = Double.doubleToRawLongBits(d);
    long diff1d = fcmPredictor.getPrediction() ^ dBits;
    long diff2d = dfcmPredictor.getPrediction() ^ dBits;
    fcmPredictor.update(dBits);
    dfcmPredictor.update(dBits);
    byte code = 0;
    if (diff1d > diff2d) {
        code |= 0x80;
        diff1d = diff2d;
    }
    int zeroBytes = Long.numberOfLeadingZeros(diff1d) >> 3;
    code |= leadingBytesToHeaderFirst[zeroBytes];
    code |= 0x06;
    buf.put(code);
    pushByteArray(buf, diff1d, zeroBytes);
    buf.put((byte) 0);
}

[Buggy Hunk]
code |= leadingBytesToHeaderFirst[zeroBytes];

[Patch]
code |= LEADING_BYTES_TO_HEADER_FIRST[zeroBytes];

[Demonstration 2]

[Buggy Method]
private static String[] getDirectories(String path) throws IOException {
    File dir;
    dir = new File(path);
    File[] files = dir.listFiles();
    ArrayList<String> fnames = new ArrayList<String>();
    for (int f = 0; f < files.length; f++) {
        if (files[f].isDirectory()) {
            fnames.add(files[f].getName());
        }
    }
    //luckily we seperated concerns and the fix was only two lines....
    Collections.sort(fnames);
    return fnames.toArray(new String[fnames.size()]);
}

[Buggy Hunk]
if (files[f].isDirectory()) {

[Patch]
if (files[f].isDirectory() && !getLeafPath(files[f].getName()).contains(".")) { //ignore hidden directories

[Demonstration 3]

[Buggy Method]
private void parseRFMessage(String msg) throws MessageParseException {
    String[] parts = splitMessage(msg);
    if (parts.length != 2) {
        throw new MessageParseException("need 2 comma separated fields in msg");
    }
    try {
        int numeric = Integer.parseInt(parts[1]);
        ArrayList<AlarmDecoderBindingConfig> bcl = getItems(ADMsgType.RFX, parts[0], null);
        for (AlarmDecoderBindingConfig c : bcl) {
            if (c.hasFeature("data")) {
                int bit = c.getIntParameter("bit", 0, 7, -1);
                // apply bitmask if requested, else publish raw number
                int v = (bit == -1) ? numeric : ((numeric >> bit) & 0x00000001);
                updateItem(c, new DecimalType(v));
            } else if (c.hasFeature("contact")) {
                // if no loop indicator bitmask is set, default to 0x50
                int bit = c.getIntParameter("bitmask", 0, 255, 0x50);
                int v = numeric & bit;
                updateItem(c, v == 0 ? OpenClosedType.CLOSED : OpenClosedType.OPEN);
            }
        }
    } catch (NumberFormatException e) {
        throw new MessageParseException("msg contains invalid state number: " + e.getMessage());
    }
}

[Buggy Hunk]
int numeric = Integer.parseInt(parts[1]);

[Patch]
int numeric = Integer.parseInt(parts[1], 16);