Skip to content

Commit 9fb979c

Browse files
Merge pull request #1705 from edenman/1.x
Issue #1642 Fix null-emitting combineLatest
2 parents ec2f991 + 3bbddaf commit 9fb979c

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/main/java/rx/internal/operators/OnSubscribeCombineLatest.java

Lines changed: 1 addition & 1 deletion
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
}

src/test/java/rx/CombineLatestTests.java

Lines changed: 23 additions & 0 deletions
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)