[Demonstration 1]

[Buggy Method]
@Override
public <Item extends RealmObject> Observable<List<Item>> getApiObservable(Observable<List<Item>> api, Class<Item> realmClass, String sortedField, List<Integer> ids) {
    if (getStorage() != null) {
        RealmResults<Item> realmResults;
        if (sortedField != null)
            realmResults = (ids == null) ? getItems(realmClass, sortedField) : getItems(realmClass, sortedField, ids);
        else
            realmResults = getItems(realmClass);
        Observable<List<Item>> realmObserver = realmResults.asObservable().filter(RealmResults::isLoaded).compose(getLifecycle()).switchMap(Observable::just);
        Observable<List<Item>> retrofitObserver = api.compose(applySchedulers()).compose(getLifecycle());
        return Observable.<List<Item>>create(subscriber -> {
            realmObserver.subscribe(subscriber::onNext, subscriber::onError);
            retrofitObserver.subscribe(this::setItems, subscriber::onError, subscriber::onCompleted);
        }).compose(getLifecycle());
    } else
        return api.compose(applySchedulers()).compose(getLifecycle());
}

[Buggy Hunk]
}).compose(getLifecycle());

[Patch]
}).compose(applySchedulers()).compose(getLifecycle());

[Demonstration 2]

[Buggy Method]
private void connected(ConnectedThread connectionThread) {
    isConnected = true;
    this.mConnectionThread = connectionThread;
    mListener.onConnectionEstablished();
}

[Buggy Hunk]
mListener.onConnectionEstablished();

[Patch]
mHandler.obtainMessage(MSG_CONNECTION_ESTABLISHED).sendToTarget();

[Demonstration 3]

[Buggy Method]
public static void main(String[] args) {
    // Configure BUNDLE scenario
    Scenario scenario = new Scenario();
    scenario.setEndTime(LocalTime.of(14, 0));
    scenario.setFirstDockingTime(LocalTime.of(12, 0));
    scenario.setOffloadingDuration(Duration.ofMinutes(5));
    scenario.setOptimalDeliveryInterval(Duration.ofMinutes(10));
    scenario.setOrderAheadMaximum(6);
    scenario.setOrderAheadMinimum(6);
    scenario.setOrderType(OrderType.SEQUENTIAL);
    scenario.setRoundtripTime(Duration.ofMinutes(20));
    scenario.setSchedulingAlgorithm(new NaiveSymetricPenalties());
    scenario.setValuator(new NonMonotonicLatenessValuation());
    scenario.setWinnerDeterminationAlgorithm(new SimpleTreeSearch());
    scenario.setStartTime(LocalTime.of(11, 40));
    scenario.setTruckCount(2);
    // Configure SEQUENTIAL scenario
    // Scenario scenario = new Scenario();
    // scenario.setEndTime(LocalTime.of(14, 0));
    // scenario.setFirstDockingTime(LocalTime.of(12, 0));
    // scenario.setOffloadingDuration(Duration.ofMinutes(5));
    // scenario.setOptimalDeliveryInterval(Duration.ofMinutes(10));
    // scenario.setOrderAheadMaximum(6);
    // scenario.setOrderAheadMinimum(6);
    // scenario.setOrderType(OrderType.SEQUENTIAL);
    // scenario.setRoundtripTime(Duration.ofMinutes(20));
    // scenario.setSchedulingAlgorithm(new NaiveSymetricPenalties());
    // scenario.setStartTime(LocalTime.of(11, 40));
    // scenario.setTruckCount(2);
    Engine engine = new Engine(new Condition() {

        @Override
        public boolean isMet() {
            // TODO Auto-generated method stub
            return false;
        }
    }, scenario);
    engine.run();
}

[Buggy Hunk]
scenario.setOrderType(OrderType.SEQUENTIAL);

[Patch]
scenario.setOrderType(OrderType.BUNDLE);