@@ -72,8 +72,11 @@ public abstract class ParallelFlowable<@NonNull T> {
72
72
*
73
73
* @param subscribers the array of Subscribers
74
74
* @return true if the number of subscribers equals to the parallelism level
75
+ * @throws NullPointerException if {@code subscribers} is {@code null}
76
+ * @throws IllegalArgumentException if {@code subscribers.length} is different from {@link #parallelism()}
75
77
*/
76
78
protected final boolean validate (@ NonNull Subscriber <?>[] subscribers ) {
79
+ Objects .requireNonNull (subscribers , "subscribers is null" );
77
80
int p = parallelism ();
78
81
if (subscribers .length != p ) {
79
82
Throwable iae = new IllegalArgumentException ("parallelism = " + p + ", subscribers = " + subscribers .length );
@@ -156,7 +159,7 @@ public static <T> ParallelFlowable<T> from(@NonNull Publisher<? extends T> sourc
156
159
@ BackpressureSupport (BackpressureKind .FULL )
157
160
public static <@ NonNull T > ParallelFlowable <T > from (@ NonNull Publisher <? extends T > source ,
158
161
int parallelism , int prefetch ) {
159
- Objects .requireNonNull (source , "source" );
162
+ Objects .requireNonNull (source , "source is null " );
160
163
ObjectHelper .verifyPositive (parallelism , "parallelism" );
161
164
ObjectHelper .verifyPositive (prefetch , "prefetch" );
162
165
@@ -183,7 +186,7 @@ public static <T> ParallelFlowable<T> from(@NonNull Publisher<? extends T> sourc
183
186
@ SchedulerSupport (SchedulerSupport .NONE )
184
187
@ BackpressureSupport (BackpressureKind .PASS_THROUGH )
185
188
public final <R > ParallelFlowable <R > map (@ NonNull Function <? super T , ? extends R > mapper ) {
186
- Objects .requireNonNull (mapper , "mapper" );
189
+ Objects .requireNonNull (mapper , "mapper is null " );
187
190
return RxJavaPlugins .onAssembly (new ParallelMap <>(this , mapper ));
188
191
}
189
192
@@ -212,7 +215,7 @@ public final <R> ParallelFlowable<R> map(@NonNull Function<? super T, ? extends
212
215
@ SchedulerSupport (SchedulerSupport .NONE )
213
216
@ BackpressureSupport (BackpressureKind .PASS_THROUGH )
214
217
public final <R > ParallelFlowable <R > map (@ NonNull Function <? super T , ? extends R > mapper , @ NonNull ParallelFailureHandling errorHandler ) {
215
- Objects .requireNonNull (mapper , "mapper" );
218
+ Objects .requireNonNull (mapper , "mapper is null " );
216
219
Objects .requireNonNull (errorHandler , "errorHandler is null" );
217
220
return RxJavaPlugins .onAssembly (new ParallelMapTry <>(this , mapper , errorHandler ));
218
221
}
@@ -243,7 +246,7 @@ public final <R> ParallelFlowable<R> map(@NonNull Function<? super T, ? extends
243
246
@ SchedulerSupport (SchedulerSupport .NONE )
244
247
@ BackpressureSupport (BackpressureKind .PASS_THROUGH )
245
248
public final <R > ParallelFlowable <R > map (@ NonNull Function <? super T , ? extends R > mapper , @ NonNull BiFunction <? super Long , ? super Throwable , ParallelFailureHandling > errorHandler ) {
246
- Objects .requireNonNull (mapper , "mapper" );
249
+ Objects .requireNonNull (mapper , "mapper is null " );
247
250
Objects .requireNonNull (errorHandler , "errorHandler is null" );
248
251
return RxJavaPlugins .onAssembly (new ParallelMapTry <>(this , mapper , errorHandler ));
249
252
}
@@ -267,7 +270,7 @@ public final <R> ParallelFlowable<R> map(@NonNull Function<? super T, ? extends
267
270
@ SchedulerSupport (SchedulerSupport .NONE )
268
271
@ BackpressureSupport (BackpressureKind .PASS_THROUGH )
269
272
public final ParallelFlowable <T > filter (@ NonNull Predicate <? super T > predicate ) {
270
- Objects .requireNonNull (predicate , "predicate" );
273
+ Objects .requireNonNull (predicate , "predicate is null " );
271
274
return RxJavaPlugins .onAssembly (new ParallelFilter <>(this , predicate ));
272
275
}
273
276
@@ -295,7 +298,7 @@ public final ParallelFlowable<T> filter(@NonNull Predicate<? super T> predicate)
295
298
@ SchedulerSupport (SchedulerSupport .NONE )
296
299
@ BackpressureSupport (BackpressureKind .PASS_THROUGH )
297
300
public final ParallelFlowable <T > filter (@ NonNull Predicate <? super T > predicate , @ NonNull ParallelFailureHandling errorHandler ) {
298
- Objects .requireNonNull (predicate , "predicate" );
301
+ Objects .requireNonNull (predicate , "predicate is null " );
299
302
Objects .requireNonNull (errorHandler , "errorHandler is null" );
300
303
return RxJavaPlugins .onAssembly (new ParallelFilterTry <>(this , predicate , errorHandler ));
301
304
}
@@ -325,7 +328,7 @@ public final ParallelFlowable<T> filter(@NonNull Predicate<? super T> predicate,
325
328
@ SchedulerSupport (SchedulerSupport .NONE )
326
329
@ BackpressureSupport (BackpressureKind .PASS_THROUGH )
327
330
public final ParallelFlowable <T > filter (@ NonNull Predicate <? super T > predicate , @ NonNull BiFunction <? super Long , ? super Throwable , ParallelFailureHandling > errorHandler ) {
328
- Objects .requireNonNull (predicate , "predicate" );
331
+ Objects .requireNonNull (predicate , "predicate is null " );
329
332
Objects .requireNonNull (errorHandler , "errorHandler is null" );
330
333
return RxJavaPlugins .onAssembly (new ParallelFilterTry <>(this , predicate , errorHandler ));
331
334
}
@@ -401,7 +404,7 @@ public final ParallelFlowable<T> runOn(@NonNull Scheduler scheduler) {
401
404
@ BackpressureSupport (BackpressureKind .FULL )
402
405
@ SchedulerSupport (SchedulerSupport .CUSTOM )
403
406
public final ParallelFlowable <T > runOn (@ NonNull Scheduler scheduler , int prefetch ) {
404
- Objects .requireNonNull (scheduler , "scheduler" );
407
+ Objects .requireNonNull (scheduler , "scheduler is null " );
405
408
ObjectHelper .verifyPositive (prefetch , "prefetch" );
406
409
return RxJavaPlugins .onAssembly (new ParallelRunOn <>(this , scheduler , prefetch ));
407
410
}
@@ -426,7 +429,7 @@ public final ParallelFlowable<T> runOn(@NonNull Scheduler scheduler, int prefetc
426
429
@ BackpressureSupport (BackpressureKind .UNBOUNDED_IN )
427
430
@ SchedulerSupport (SchedulerSupport .NONE )
428
431
public final Flowable <T > reduce (@ NonNull BiFunction <T , T , T > reducer ) {
429
- Objects .requireNonNull (reducer , "reducer" );
432
+ Objects .requireNonNull (reducer , "reducer is null " );
430
433
return RxJavaPlugins .onAssembly (new ParallelReduceFull <>(this , reducer ));
431
434
}
432
435
@@ -453,8 +456,8 @@ public final Flowable<T> reduce(@NonNull BiFunction<T, T, T> reducer) {
453
456
@ BackpressureSupport (BackpressureKind .UNBOUNDED_IN )
454
457
@ SchedulerSupport (SchedulerSupport .NONE )
455
458
public final <R > ParallelFlowable <R > reduce (@ NonNull Supplier <R > initialSupplier , @ NonNull BiFunction <R , ? super T , R > reducer ) {
456
- Objects .requireNonNull (initialSupplier , "initialSupplier" );
457
- Objects .requireNonNull (reducer , "reducer" );
459
+ Objects .requireNonNull (initialSupplier , "initialSupplier is null " );
460
+ Objects .requireNonNull (reducer , "reducer is null " );
458
461
return RxJavaPlugins .onAssembly (new ParallelReduce <>(this , initialSupplier , reducer ));
459
462
}
460
463
@@ -1024,13 +1027,15 @@ public final <C> ParallelFlowable<C> collect(@NonNull Supplier<? extends C> coll
1024
1027
* @param <T> the value type
1025
1028
* @param publishers the array of publishers
1026
1029
* @return the new ParallelFlowable instance
1030
+ * @throws IllegalArgumentException if {@code publishers} is an empty array
1027
1031
*/
1028
1032
@ CheckReturnValue
1029
1033
@ NonNull
1030
1034
@ SafeVarargs
1031
1035
@ BackpressureSupport (BackpressureKind .PASS_THROUGH )
1032
1036
@ SchedulerSupport (SchedulerSupport .NONE )
1033
1037
public static <@ NonNull T > ParallelFlowable <T > fromArray (@ NonNull Publisher <T >... publishers ) {
1038
+ Objects .requireNonNull (publishers , "publishers is null" );
1034
1039
if (publishers .length == 0 ) {
1035
1040
throw new IllegalArgumentException ("Zero publishers not supported" );
1036
1041
}
@@ -1427,7 +1432,7 @@ public final <U> ParallelFlowable<U> flatMapIterable(@NonNull Function<? super T
1427
1432
@ SchedulerSupport (SchedulerSupport .NONE )
1428
1433
@ BackpressureSupport (BackpressureKind .PASS_THROUGH )
1429
1434
public final <R > ParallelFlowable <R > mapOptional (@ NonNull Function <? super T , Optional <? extends R >> mapper ) {
1430
- Objects .requireNonNull (mapper , "mapper" );
1435
+ Objects .requireNonNull (mapper , "mapper is null " );
1431
1436
return RxJavaPlugins .onAssembly (new ParallelMapOptional <>(this , mapper ));
1432
1437
}
1433
1438
@@ -1456,7 +1461,7 @@ public final <R> ParallelFlowable<R> mapOptional(@NonNull Function<? super T, Op
1456
1461
@ SchedulerSupport (SchedulerSupport .NONE )
1457
1462
@ BackpressureSupport (BackpressureKind .PASS_THROUGH )
1458
1463
public final <R > ParallelFlowable <R > mapOptional (@ NonNull Function <? super T , Optional <? extends R >> mapper , @ NonNull ParallelFailureHandling errorHandler ) {
1459
- Objects .requireNonNull (mapper , "mapper" );
1464
+ Objects .requireNonNull (mapper , "mapper is null " );
1460
1465
Objects .requireNonNull (errorHandler , "errorHandler is null" );
1461
1466
return RxJavaPlugins .onAssembly (new ParallelMapTryOptional <>(this , mapper , errorHandler ));
1462
1467
}
@@ -1487,7 +1492,7 @@ public final <R> ParallelFlowable<R> mapOptional(@NonNull Function<? super T, Op
1487
1492
@ SchedulerSupport (SchedulerSupport .NONE )
1488
1493
@ BackpressureSupport (BackpressureKind .PASS_THROUGH )
1489
1494
public final <R > ParallelFlowable <R > mapOptional (@ NonNull Function <? super T , Optional <? extends R >> mapper , @ NonNull BiFunction <? super Long , ? super Throwable , ParallelFailureHandling > errorHandler ) {
1490
- Objects .requireNonNull (mapper , "mapper" );
1495
+ Objects .requireNonNull (mapper , "mapper is null " );
1491
1496
Objects .requireNonNull (errorHandler , "errorHandler is null" );
1492
1497
return RxJavaPlugins .onAssembly (new ParallelMapTryOptional <>(this , mapper , errorHandler ));
1493
1498
}
0 commit comments