[Demonstration 1]

[Buggy Method]
public void updateDevices() {
    systemCallDriverBTBluetoothDriverGetDevices(returnCodeWrapper, btReturnCodeWrapper, intArrayWrapper);
    if (btReturnCodeWrapper.value != BtReturnCode.OK) {
        throw new BtKernelException(btReturnCodeWrapper.value);
    }
    if (returnCodeWrapper.value != ReturnCode.OK) {
        throw new KernelException(returnCodeWrapper.value);
    }
    for (int i = 0; i < intArrayWrapper.value.length; i++) {
        boolean alreadyConnected = false;
        for (int j = 0; j < devices.size(); j++) {
            if (devices.get(j).getId() == intArrayWrapper.value[i]) {
                alreadyConnected = true;
                break;
            }
        }
        if (!alreadyConnected) {
            Device device = new Device(intArrayWrapper.value[i]);
            devices.add(device);
            for (int k = 0; k < connectedHandlers.size(); k++) {
                connectedHandlers.get(k).handle(device);
            }
        }
    }
    for (int i = 0; i < devices.size(); i++) {
        boolean stillConnected = false;
        for (int j = 0; j < intArrayWrapper.value.length; j++) {
            if (devices.get(i).getId() == intArrayWrapper.value[j]) {
                stillConnected = true;
                break;
            }
        }
        if (!stillConnected) {
            devices.remove(devices.get(i));
            for (int k = 0; k < disconnectedHandlers.size(); k++) {
                disconnectedHandlers.get(k).handle(devices.get(i));
            }
        }
    }
}

[Buggy Hunk]
public void updateDevices(){

[Patch]
public static void updateDevices(){

[Demonstration 2]

[Buggy Method]
private void CheckForNewLock(BluetoothDevice device) {
    Log.d(TAG, "A device has been connected. Checking the device list to see if it is new");
    SmartLock sl;
    if (!lockManager.getLocks().containsKey(device.getAddress())) {
        sl = lockManager.addLock(device);
        lockManager.localSave(this);
    } else {
        sl = lockManager.getLocks().get(device.getAddress());
    }
    sl.setIsConnected(true);
    mLockArrayAdapter.notifyDataSetChanged();
}

[Buggy Hunk]
private void CheckForNewLock(BluetoothDevice device) {

[Patch]
private synchronized void CheckForNewLock(BluetoothDevice device) {

[Demonstration 3]

[Buggy Method]
private static URL[] convertToURL(String[] paths) {
    return Arrays.stream(paths).map(File::new).map(File::toURI).map(uri -> {
        try {
            return uri.toURL();
        } catch (MalformedURLException e) {
            throw new RuntimeException(e);
        }
    }).toArray(URL[]::new);
}

[Buggy Hunk]
private static URL[] convertToURL(String[] paths) {

[Patch]
private URL[] convertToURL(String[] paths) {