File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed
test/java/rx/internal/operators Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -5403,9 +5403,14 @@ public final Observable<T> defaultIfEmpty(final T defaultValue) {
54035403 * the alternate Observable to subscribe to if the source does not emit any items
54045404 * @return an Observable that emits the items emitted by the source Observable or the items of an
54055405 * alternate Observable if the source Observable is empty.
5406+ * @throws NullPointerException
5407+ * if {@code alternate} is null
54065408 * @since 1.1.0
54075409 */
54085410 public final Observable<T> switchIfEmpty(Observable<? extends T> alternate) {
5411+ if (alternate == null) {
5412+ throw new NullPointerException("alternate is null");
5413+ }
54095414 return lift(new OperatorSwitchIfEmpty<T>(alternate));
54105415 }
54115416
Original file line number Diff line number Diff line change @@ -207,4 +207,9 @@ public void call() {
207207 ts .assertValueCount (2 );
208208 ts .unsubscribe ();
209209 }
210+
211+ @ Test (expected = NullPointerException .class )
212+ public void testAlternateNull () {
213+ Observable .just (1 ).switchIfEmpty (null );
214+ }
210215}
You can’t perform that action at this time.
0 commit comments