Skip to content

Commit 22b2e47

Browse files
Merge pull request ReactiveX#190 from prabirshrestha/chainDematerialize
update dematerialize so can chain correctly
2 parents bdd91eb + cda38ea commit 22b2e47

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

rxjava-core/src/main/java/rx/Observable.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2598,8 +2598,8 @@ public Observable<Notification<T>> materialize() {
25982598
* if attempted on Observable not of type {@code Observable<Notification<T>>}.
25992599
*/
26002600
@SuppressWarnings("unchecked")
2601-
public Observable<T> dematerialize() {
2602-
return dematerialize((Observable<Notification<T>>) this);
2601+
public <T2> Observable<T2> dematerialize() {
2602+
return dematerialize((Observable<Notification<T2>>)this);
26032603
}
26042604

26052605
/**
@@ -3461,6 +3461,19 @@ public void testLastEmptyObservable() {
34613461
assertNull(obs.last());
34623462
}
34633463

3464+
@Test
3465+
public void testMaterializeDematerializeChaining() {
3466+
Observable<Integer> obs = Observable.just(1);
3467+
Observable<Integer> chained = obs.materialize().dematerialize();
3468+
3469+
Observer<Integer> observer = mock(Observer.class);
3470+
chained.subscribe(observer);
3471+
3472+
verify(observer, times(1)).onNext(1);
3473+
verify(observer, times(1)).onCompleted();
3474+
verify(observer, times(0)).onError(any(Exception.class));
3475+
}
3476+
34643477
private static class TestException extends RuntimeException {
34653478
private static final long serialVersionUID = 1L;
34663479
}

0 commit comments

Comments
 (0)