Skip to content

Commit a45b1c1

Browse files
Merge pull request #1761 from edenman/0.20.x
Issue #1642 Fix null-emitting combineLatest
2 parents 8c2986d + 1eff6b4 commit a45b1c1

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

rxjava-core/src/main/java/rx/internal/operators/OnSubscribeCombineLatest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ void tick() {
150150
if (buffer.isCompleted(o)) {
151151
child.onCompleted();
152152
} else {
153-
child.onNext((R) o);
153+
child.onNext(NotificationLite.<R>instance().getValue(o));
154154
emitted++;
155155
requested.decrementAndGet();
156156
}

rxjava-core/src/test/java/rx/CombineLatestTests.java

+23
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
import rx.CovarianceTest.Result;
2727
import rx.functions.Action1;
2828
import rx.functions.Func2;
29+
import rx.subjects.BehaviorSubject;
30+
31+
import static org.junit.Assert.assertNull;
32+
import static rx.Observable.combineLatest;
2933

3034
public class CombineLatestTests {
3135
/**
@@ -65,4 +69,23 @@ public void call(ExtendedResult t1) {
6569
System.out.println("Result: " + t1);
6670
}
6771
};
72+
73+
@Test
74+
public void testNullEmitting() throws Exception {
75+
Observable<Boolean> nullObservable = BehaviorSubject.create((Boolean) null);
76+
Observable<Boolean> nonNullObservable = BehaviorSubject.create(true);
77+
Observable<Boolean> combined =
78+
combineLatest(nullObservable, nonNullObservable, new Func2<Boolean, Boolean, Boolean>() {
79+
@Override
80+
public Boolean call(Boolean bool1, Boolean bool2) {
81+
return bool1 == null ? null : bool2;
82+
}
83+
});
84+
combined.subscribe(new Action1<Boolean>() {
85+
@Override
86+
public void call(Boolean aBoolean) {
87+
assertNull(aBoolean);
88+
}
89+
});
90+
}
6891
}

0 commit comments

Comments
 (0)