[Demonstration 1]

[Buggy Method]
public String toString() {
    if (this.getAddress2() != null)
        return String.format("%s, %s, %s, %s %s", this.getAddress1(), this.getAddress2(), this.getCity(), this.getState(), this.getZip());
    else
        return String.format("%s, %s, %s %s", this.getAddress1(), this.getCity(), this.getState(), this.getZip());
}

[Buggy Hunk]
if (this.getAddress2() != null)

[Patch]
if (this.getAddress2() != null && !this.getAddress2().equals(""))

[Demonstration 2]

[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 (StringUtils.isBlank(serialNumber)) {

[Demonstration 3]

[Buggy Method]
public void moveAtPower(int power) {
    logger.info("moveAtPower: " + power);
    this.interrupt = true;
    if (power == 0)
        return;
    final int powerFinal = this.power;
    new Thread(new Runnable() {

        @Override
        public void run() {
            pwm(powerFinal);
        }
    }).start();
}

[Buggy Hunk]
final int powerFinal = this.power;

[Patch]
final int powerFinal = power;