File tree 2 files changed +10
-0
lines changed
test/java/rx/internal/operators
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) {
5403
5403
* the alternate Observable to subscribe to if the source does not emit any items
5404
5404
* @return an Observable that emits the items emitted by the source Observable or the items of an
5405
5405
* alternate Observable if the source Observable is empty.
5406
+ * @throws NullPointerException
5407
+ * if {@code alternate} is null
5406
5408
* @since 1.1.0
5407
5409
*/
5408
5410
public final Observable<T> switchIfEmpty(Observable<? extends T> alternate) {
5411
+ if (alternate == null) {
5412
+ throw new NullPointerException("alternate is null");
5413
+ }
5409
5414
return lift(new OperatorSwitchIfEmpty<T>(alternate));
5410
5415
}
5411
5416
Original file line number Diff line number Diff line change @@ -207,4 +207,9 @@ public void call() {
207
207
ts .assertValueCount (2 );
208
208
ts .unsubscribe ();
209
209
}
210
+
211
+ @ Test (expected = NullPointerException .class )
212
+ public void testAlternateNull () {
213
+ Observable .just (1 ).switchIfEmpty (null );
214
+ }
210
215
}
You can’t perform that action at this time.
0 commit comments