[Demonstration 1]

[Buggy Method]
public SerialMessage setInterval(int interval) {
    logger.debug("NODE {}: Creating new message for application command WAKE_UP_INTERVAL_SET to {}", this.getNode().getNodeId(), interval);
    SerialMessage result = new SerialMessage(this.getNode().getNodeId(), SerialMessageClass.SendData, SerialMessageType.Request, SerialMessageClass.ApplicationCommandHandler, SerialMessagePriority.Get);
    byte[] newPayload = { (byte) this.getNode().getNodeId(), 6, (byte) getCommandClass().getKey(), (byte) WAKE_UP_INTERVAL_SET, (byte) ((interval >> 16) & 0xff), (byte) ((interval >> 8) & 0xff), (byte) (interval & 0xff), (byte) getController().getOwnNodeId() };
    result.setMessagePayload(newPayload);
    byte[] buffer = result.getMessageBuffer();
    logger.debug("NODE {}: Sending REQUEST Message = {}", result.getMessageNode(), SerialMessage.bb2hex(buffer));
    return result;
}

[Buggy Hunk]
SerialMessage result = new SerialMessage(this.getNode().getNodeId(), SerialMessageClass.SendData, SerialMessageType.Request, SerialMessageClass.ApplicationCommandHandler, SerialMessagePriority.Get);

[Patch]
SerialMessage result = new SerialMessage(this.getNode().getNodeId(), SerialMessageClass.SendData, SerialMessageType.Request, SerialMessageClass.SendData, SerialMessagePriority.Get);

[Demonstration 2]

[Buggy Method]
private void initialiseZigBee() {
    logger.debug("Initialising ZigBee coordinator");
    // Start the discovery service
    discoveryService = new ZigBeeDiscoveryService(this);
    discoveryService.activate();
    // And register it as an OSGi service
    discoveryRegistration = bundleContext.registerService(DiscoveryService.class.getName(), discoveryService, new Hashtable<String, Object>());
    // ZigBeeNetworkStateSerializer networkStateSerializer = new ZigBeeNetworkStateSerializerImpl();
    // Configure the network manager
    networkManager = new ZigBeeNetworkManager(zigbeeTransport);
    // networkManager.setNetworkStateSerializer(networkStateSerializer);
    networkManager.setSerializer(serializerClass, deserializerClass);
    networkManager.addNetworkStateListener(this);
    networkManager.addNetworkNodeListener(this);
    logger.debug("Key initialise {}", networkKey);
    // Initialise the network
    ZigBeeInitializeResponse initResponse = networkManager.initialize();
    if (initResponse == ZigBeeInitializeResponse.FAILED) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, getI18nConstant(ZigBeeBindingConstants.OFFLINE_INITIALIZE_FAIL));
        return;
    }
    logger.debug("initResponse is {}", initResponse);
    // If we're not joined, then join
    if (initResponse == ZigBeeInitializeResponse.NOT_JOINED) {
        initializeNetwork = true;
    }
    logger.debug("initializeNetwork is {}", initializeNetwork);
    // Get the initial network configuration
    int currentChannel = networkManager.getZigBeeChannel();
    int currentPanId = networkManager.getZigBeePanId();
    ExtendedPanId currentExtendedPanId = networkManager.getZigBeeExtendedPanId();
    if (initializeNetwork) {
        networkManager.setZigBeeSecurityKey(networkKey);
        networkManager.setZigBeeChannel(channelId);
        networkManager.setZigBeePanId(panId);
        networkManager.setZigBeeExtendedPanId(extendedPanId);
    }
    // Call startup. The setting of the bring to ONLINE will be done via the state listener.
    if (!networkManager.startup(initializeNetwork)) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, getI18nConstant(ZigBeeBindingConstants.OFFLINE_STARTUP_FAIL));
        return;
    }
    // Get the final network configuration
    currentChannel = networkManager.getZigBeeChannel();
    currentPanId = networkManager.getZigBeePanId();
    currentExtendedPanId = networkManager.getZigBeeExtendedPanId();
    logger.debug("Initialise done....... {}  {}  {}", currentChannel, currentPanId, currentExtendedPanId);
    try {
        // Persist the network configuration
        Configuration configuration = editConfiguration();
        configuration.put(CONFIGURATION_PANID, currentPanId);
        configuration.put(CONFIGURATION_EXTENDEDPANID, String.format("%016X", currentExtendedPanId));
        configuration.put(CONFIGURATION_CHANNEL, currentChannel);
        // If the thing is defined statically, then this will fail and we will never start!
        updateConfiguration(configuration);
    } catch (IllegalStateException e) {
        logger.debug("Error updating configuration", e);
    }
}

[Buggy Hunk]
configuration.put(CONFIGURATION_EXTENDEDPANID, String.format("%016X", currentExtendedPanId));

[Patch]
configuration.put(CONFIGURATION_EXTENDEDPANID, currentExtendedPanId.toString());

[Demonstration 3]

[Buggy Method]
private List<ParseTreeNode> promoteHighPriorityTerminals(List<ParseTreeNode> nodes) {
    List<ParseTreeNode> result = nodes;
    List<SyntaxCase> syntaxCases = new ArrayList<>();
    for (SyntaxCase sc : grammar.getPriorityCaseList().stream().map(Pair::getSecond).collect(Collectors.toList())) {
        if (!isOnlyTerminals(sc))
            break;
        syntaxCases.add(sc);
    }
    for (SyntaxCase s : syntaxCases) {
        List<ParseTreeNode> tmp = new ArrayList<>();
        int window = s.getStructure().size();
        int start = 0;
        while (start <= result.size() - window) {
            int end = start + window;
            List<ParseTreeNode> currentSubList = result.subList(start, end);
            SyntaxCase instanceCase = new SyntaxCase("", null, currentSubList.stream().map(a -> a.isTerminal() ? a.getTokenCategory() : new SyntaxParsingInstance(a.getSyntaxClass(), a.getSyntaxCase())).collect(Collectors.toList()).toArray(new SyntaxCaseComponent[currentSubList.size()]));
            boolean caseMatch = Grammar.caseMatch(instanceCase, s);
            if (caseMatch) {
                tmp.add(newNonTerminalNode(s.getBelongingClass(), s, currentSubList));
                start += window - 1;
            } else
                tmp.add(currentSubList.get(0));
            ++start;
        }
        for (int i = start; i < result.size(); ++i) result.add(result.get(i));
        result = tmp;
    }
    return result;
}

[Buggy Hunk]
result.add(result.get(i));

[Patch]
tmp.add(result.get(i));