Skip to content

Commit

Permalink
Merge pull request #1761 from edenman/0.20.x
Browse files Browse the repository at this point in the history
Issue #1642 Fix null-emitting combineLatest
  • Loading branch information
benjchristensen committed Oct 16, 2014
2 parents 8c2986d + 1eff6b4 commit a45b1c1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void tick() {
if (buffer.isCompleted(o)) {
child.onCompleted();
} else {
child.onNext((R) o);
child.onNext(NotificationLite.<R>instance().getValue(o));
emitted++;
requested.decrementAndGet();
}
Expand Down
23 changes: 23 additions & 0 deletions rxjava-core/src/test/java/rx/CombineLatestTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
import rx.CovarianceTest.Result;
import rx.functions.Action1;
import rx.functions.Func2;
import rx.subjects.BehaviorSubject;

import static org.junit.Assert.assertNull;
import static rx.Observable.combineLatest;

public class CombineLatestTests {
/**
Expand Down Expand Up @@ -65,4 +69,23 @@ public void call(ExtendedResult t1) {
System.out.println("Result: " + t1);
}
};

@Test
public void testNullEmitting() throws Exception {
Observable<Boolean> nullObservable = BehaviorSubject.create((Boolean) null);
Observable<Boolean> nonNullObservable = BehaviorSubject.create(true);
Observable<Boolean> combined =
combineLatest(nullObservable, nonNullObservable, new Func2<Boolean, Boolean, Boolean>() {
@Override
public Boolean call(Boolean bool1, Boolean bool2) {
return bool1 == null ? null : bool2;
}
});
combined.subscribe(new Action1<Boolean>() {
@Override
public void call(Boolean aBoolean) {
assertNull(aBoolean);
}
});
}
}

0 comments on commit a45b1c1

Please sign in to comment.