[Demonstration 1]

[Buggy Method]
@Override
public void channelRead(ChannelHandlerContext ctx, Object msg) {
    final ByteBuf messageByteBuf = (ByteBuf) msg;
    final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    while (messageByteBuf.isReadable()) byteArrayOutputStream.write(messageByteBuf.readByte());
    final byte[] messageBytes = byteArrayOutputStream.toByteArray();
    if (TCPTunnelServer.DEBUG_MODE)
        LOGGER.debug("Received message: {}", Wireshark.getSubstring(messageBytes));
    if (baseHandler == null)
        try {
            TunnelProto.TunnelCommand tunnelCommand = TunnelProto.TunnelCommand.parseFrom(messageBytes);
            switch(tunnelCommand.getMethod()) {
                case CONTROLLER_INIT:
                    baseHandler = new ControllerHandler(this);
                    ((ControllerHandler) baseHandler).sendControllerId();
                    new ForwardingServer((ControllerHandler) baseHandler);
                    break;
                case TUNNEL_INIT:
                    baseHandler = new TunnelHandler(this);
                    String controllerId = tunnelCommand.getMessage().split(ControllerServer.DELIMITER)[0];
                    ControllerHandler.addTunnelHanlder(controllerId, (TunnelHandler) baseHandler);
                    break;
                default:
                    LOGGER.warn("method unrecognized");
            }
        } catch (InvalidProtocolBufferException e) {
            LOGGER.catching(e);
        }
    else if (baseHandler instanceof TunnelHandler) {
        ((TunnelHandler) baseHandler).write(messageBytes);
    }
    ReferenceCountUtil.release(msg);
}

[Buggy Hunk]
((TunnelHandler)baseHandler).write(messageBytes);

[Patch]
((TunnelHandler)baseHandler).forward(messageBytes);

[Demonstration 2]

[Buggy Method]
public WordBag seriesToWordBag(String label, double[] ts, Params params) throws SAXException {
    WordBag resultBag = new WordBag(label);
    // scan across the time series extract sub sequences, and convert them to strings
    char[] previousString = null;
    for (int i = 0; i < ts.length - params.windowSize; i++) {
        // fix the current subsection
        double[] subSection = Arrays.copyOfRange(ts, i, i + params.windowSize);
        // Z normalize it
        subSection = tp.znorm(subSection, params.nThreshold);
        // perform PAA conversion if needed
        double[] paa = tp.paa(subSection, params.paaSize);
        // Convert the PAA to a string.
        char[] currentString = tp.ts2String(paa, na.getCuts(params.alphabetSize));
        if (null != previousString) {
            if (NumerosityReductionStrategy.EXACT.equals(params.nrStartegy) && Arrays.equals(previousString, currentString)) {
                // NumerosityReduction
                continue;
            } else if (NumerosityReductionStrategy.MINDIST.equals(params.nrStartegy) && sp.checkMinDistIsZero(previousString, currentString)) {
                continue;
            }
        }
        previousString = currentString;
        resultBag.addWord(String.valueOf(currentString));
    }
    return resultBag;
}

[Buggy Hunk]
for (int i = 0; i < ts.length - params.windowSize; i++) {

[Patch]
for (int i = 0; i <= ts.length - params.windowSize; i++) {

[Demonstration 3]

[Buggy Method]
@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    //noinspection SimplifiableIfStatement
    if (id == R.id.action_submit) {
        try {
            TestFactory.writeJSONToServer(test, username);
        } catch (IOException e) {
            e.printStackTrace();
        }
        Intent intent = new Intent(QuestionActivity.this, SummaryActivity.class);
        startActivity(intent);
        return true;
    }
    return super.onOptionsItemSelected(item);
}

[Buggy Hunk]
e.printStackTrace();

[Patch]
Log.e(TAG, "Error while submitting test data to server.", e);