[Demonstration 1]

[Buggy Method]
@Override
public void internalReceiveCommand(String itemName, Command command) {
    logger.debug("Received command from {}", itemName);
    // resolve serial number for item
    String serialNumber = null;
    for (MaxCubeBindingProvider provider : providers) {
        serialNumber = provider.getSerialNumber(itemName);
        if (serialNumber.equals(null)) {
            continue;
        }
        // send command to MAX!Cube LAN Gateway
        Device device = findDevice(serialNumber, devices);
        if (device == null) {
            logger.debug("Cannot send command to device with serial number {}, device not listed.", serialNumber);
            continue;
        }
        String rfAddress = device.getRFAddress();
        String commandString = null;
        if (command instanceof DecimalType || command instanceof OnOffType) {
            DecimalType decimalType = DEFAULT_OFF_TEMPERATURE;
            if (command instanceof DecimalType) {
                decimalType = (DecimalType) command;
            } else if (command instanceof OnOffType) {
                decimalType = OnOffType.ON.equals(command) ? DEFAULT_ON_TEMPERATURE : DEFAULT_OFF_TEMPERATURE;
            }
            S_Command cmd = new S_Command(rfAddress, device.getRoomId(), ((HeatingThermostat) device).getMode(), decimalType.doubleValue());
            commandString = cmd.getCommandString();
        } else if (command instanceof StringType) {
            String commandContent = command.toString().trim().toUpperCase();
            S_Command cmd = null;
            ThermostatModeType commandThermoType = null;
            if (commandContent.contentEquals(ThermostatModeType.AUTOMATIC.toString())) {
                commandThermoType = ThermostatModeType.AUTOMATIC;
                cmd = new S_Command(rfAddress, device.getRoomId(), commandThermoType);
            } else if (commandContent.contentEquals(ThermostatModeType.BOOST.toString())) {
                commandThermoType = ThermostatModeType.BOOST;
                Double setTemp = Double.parseDouble(((HeatingThermostat) device).getTemperatureSetpoint().toString());
                cmd = new S_Command(rfAddress, device.getRoomId(), commandThermoType, setTemp);
            } else if (commandContent.contentEquals(ThermostatModeType.MANUAL.toString())) {
                commandThermoType = ThermostatModeType.MANUAL;
                Double setTemp = Double.parseDouble(((HeatingThermostat) device).getTemperatureSetpoint().toString());
                cmd = new S_Command(rfAddress, device.getRoomId(), commandThermoType, setTemp);
                logger.debug("updates to MANUAL mode with temperature '{}'", setTemp);
            } else {
                logger.debug("Only updates to AUTOMATIC, MANUAL & BOOST supported, received value ;'{}'", commandContent);
                continue;
            }
            commandString = cmd.getCommandString();
        }
        if (commandString != null) {
            try {
                if (socket == null) {
                    this.socketConnect();
                }
                /*DataOutputStream stream = new DataOutputStream(socket.getOutputStream());

					byte[] b = commandString.getBytes();
					stream.write(b);*/
                writer.write(commandString);
                logger.debug(commandString);
                writer.flush();
                String raw = reader.readLine();
                Message message = processRawMessage(raw);
                if (message != null) {
                    if (message.getType() == MessageType.S) {
                        sMessageProcessing((S_Message) message);
                    }
                }
                if (!exclusive) {
                    socket.close();
                    socket = null;
                }
            } catch (UnknownHostException e) {
                logger.info("Host error occurred while connecting to MAX! Cube lan gateway '{}': {}", ip, e.getMessage());
                socketClose();
            } catch (IOException e) {
                logger.info("IO error occurred while writing to MAX! Cube lan gateway '{}': {}", ip, e.getMessage());
                //reconnect on next execution
                socketClose();
            } catch (Exception e) {
                logger.info("Error occurred while writing to MAX! Cube lan gateway '{}': {}", ip, e.getMessage());
                logger.info(Utils.getStackTrace(e));
                //reconnect on next execution
                socketClose();
            }
            logger.debug("Command Sent to {}", ip);
        } else {
            logger.debug("Null Command not sent to {}", ip);
        }
    }
}

[Buggy Hunk]
if (serialNumber.equals(null)) {

[Patch]
if (serialNumber==null || StringUtils.isBlank(serialNumber)) {

[Demonstration 2]

[Buggy Method]
public Future<BigInteger> asyncCall() {
    BigInteger operand1 = new BigInteger("0");
    BigInteger operand2 = new BigInteger("5");
    BigInteger i = new BigInteger("0");
    while (operand1.bitLength() < 29) {
        operand1 = operand1.add(operand2);
        i = i.add(new BigInteger("1"));
    }
    if (context.wasCancelCalled()) {
        return new AsyncResult<>(new BigInteger("-1"));
    } else {
        LOGGER.info("I'm finished");
        return new AsyncResult<>(i);
    }
}

[Buggy Hunk]
LOGGER.info("I'm finished");

[Patch]
logger.info("I'm finished");

[Demonstration 3]

[Buggy Method]
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
    logger.error("Unexpected command for {}: {} - {}", getThing().getBridgeUID().getAsString(), channelUID, command);
}

[Buggy Hunk]
logger.error("Unexpected command for {}: {} - {}", getThing().getBridgeUID().getAsString(), channelUID, command);

[Patch]
logger.error("Unexpected command for HomeWorks Bridge: {} - {}", channelUID, command);