[Demonstration 1]

[Buggy Method]
private synchronized void updateData() {
    logger.info("Update Roku data '{}'", getThing().getUID());
    String ipAddress = (String) this.getConfig().get(IP_ADDRESS);
    Number port = (Number) this.getConfig().get(PORT);
    RokuState state = new RokuState(new RokuCommunication(ipAddress, port));
    try {
        state.updateDeviceInformation();
    } catch (IOException e) {
        logger.debug("Roku device '{}' but is not communicating", ipAddress, e);
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.toString());
    }
    try {
        updateState(CHANNEL_STATUS, state.getPowerMode());
        updateState(CHANNEL_ACTIVE, state.getActive());
        updateState(CHANNEL_UDN, state.getUdn());
        updateState(CHANNEL_SERIAL, state.getSerialNumber());
        updateState(CHANNEL_DEVICEID, state.getDeviceId());
        updateState(CHANNEL_ADID, state.getAdvertisingId());
        updateState(CHANNEL_VENDOR, state.getVendorName());
        updateState(CHANNEL_MODELNAME, state.getModelName());
        updateState(CHANNEL_MODELNUMBER, state.getModelNumber());
        updateState(CHANNEL_MODELREGION, state.getModelRegion());
        updateState(CHANNEL_WIFI, state.getWifiMac());
        updateState(CHANNEL_ETHERNET, state.getEthernetMac());
        updateState(CHANNEL_NETWORK, state.getNetworkType());
        updateState(CHANNEL_DEVICENAME, state.getUserDeviceName());
        updateState(CHANNEL_SOFTWAREV, state.getSoftwareVersion());
        updateState(CHANNEL_SOFTWAREB, state.getSoftwareBuild());
        updateState(CHANNEL_SECUREDEVICE, state.getSecureDevice());
        updateState(CHANNEL_LANGUAGE, state.getLanguage());
        updateState(CHANNEL_COUNTRY, state.getCountry());
        updateState(CHANNEL_LOCALE, state.getLocale());
        updateState(CHANNEL_TIMEZONE, state.getTimeZone());
        updateState(CHANNEL_TIMEZONEOFF, state.getTimeZoneOffSet());
        updateState(CHANNEL_SUSPENDED, state.getSupportSuspend());
        updateState(CHANNEL_DEVELOPERENABLED, state.getDeveloperEnabled());
        updateState(CHANNEL_SEARCHENABLED, state.getSearchEnabled());
        updateState(CHANNEL_VOICESEARCHENABLED, state.getVoiceSearchEnabled());
        updateState(CHANNEL_NOTIFICATIONSENABLED, state.getNotificationsEnabled());
        updateState(CHANNEL_HEADPHONESCONNECTED, state.getHeadphonesConnected());
        updateState(CHANNEL_ICON, state.getActiveImage());
        /**
         * Future Functionality
         * updateState(CHANNEL_APPBROWSER, state.getApplicationMenu());
         */
        if (!state.getPowerMode().toFullString().matches("PowerOn")) {
            updateStatus(ThingStatus.OFFLINE);
        } else {
            if (!getThing().getStatus().equals(ThingStatus.ONLINE)) {
                updateStatus(ThingStatus.ONLINE);
            }
        }
    } catch (NullPointerException e) {
        updateStatus(ThingStatus.UNINITIALIZED, ThingStatusDetail.COMMUNICATION_ERROR, e.toString());
    }
}

[Buggy Hunk]
updateStatus(ThingStatus.UNINITIALIZED, ThingStatusDetail.COMMUNICATION_ERROR, e.toString());

[Patch]
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.toString());

[Demonstration 2]

[Buggy Method]
@Override
public synchronized void serialEvent(SerialPortEvent serialPortEvent) {
    if (serialPortEvent.getEventType() == SerialPortEvent.DATA_AVAILABLE) {
        try {
            while (true) {
                String messageLine = serialInput.readLine();
                if (messageLine == null) {
                    break;
                }
                handleIncomingMessage(messageLine);
            }
        } catch (Exception e) {
            logger.error("Error reading from serial port.", e);
            updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Error reading from port");
        }
    }
}

[Buggy Hunk]
public synchronized void serialEvent(SerialPortEvent serialPortEvent) {

[Patch]
public void serialEvent(SerialPortEvent serialPortEvent) {

[Demonstration 3]

[Buggy Method]
@Override
public List<Link> getAllLink(Long messageId) {
    return messageRepo.getOne(messageId).getLinks();
}

[Buggy Hunk]
return messageRepo.getOne(messageId).getLinks();

[Patch]
return linkRepo.getAllLinks(messageId);