From 9e910de047d1c54fb4f6d26315731252857e7fae Mon Sep 17 00:00:00 2001 From: akarnokd Date: Mon, 17 Jun 2019 18:28:05 +0200 Subject: [PATCH 1/3] 3.x: Widen functional interface throws, replace Callable with Supplier --- src/main/java/io/reactivex/Completable.java | 10 +- src/main/java/io/reactivex/Flowable.java | 154 ++++++++--------- src/main/java/io/reactivex/Maybe.java | 16 +- src/main/java/io/reactivex/Observable.java | 162 +++++++++--------- src/main/java/io/reactivex/Single.java | 20 +-- .../java/io/reactivex/functions/Action.java | 4 +- .../io/reactivex/functions/BiConsumer.java | 4 +- .../io/reactivex/functions/BiFunction.java | 4 +- .../io/reactivex/functions/BiPredicate.java | 4 +- .../reactivex/functions/BooleanSupplier.java | 4 +- .../io/reactivex/functions/Cancellable.java | 4 +- .../java/io/reactivex/functions/Consumer.java | 4 +- .../java/io/reactivex/functions/Function.java | 4 +- .../io/reactivex/functions/Function3.java | 4 +- .../io/reactivex/functions/Function4.java | 4 +- .../io/reactivex/functions/Function5.java | 4 +- .../io/reactivex/functions/Function6.java | 4 +- .../io/reactivex/functions/Function7.java | 4 +- .../io/reactivex/functions/Function8.java | 4 +- .../io/reactivex/functions/Function9.java | 4 +- .../io/reactivex/functions/IntFunction.java | 4 +- .../io/reactivex/functions/LongConsumer.java | 4 +- .../io/reactivex/functions/Predicate.java | 4 +- .../java/io/reactivex/functions/Supplier.java | 33 ++++ .../disposables/CancellableDisposable.java | 2 +- .../internal/functions/Functions.java | 79 ++++++--- ...calarCallable.java => ScalarSupplier.java} | 10 +- .../internal/fuseable/SimpleQueue.java | 4 +- .../completable/CompletableDefer.java | 9 +- .../completable/CompletableErrorSupplier.java | 11 +- .../completable/CompletableToSingle.java | 9 +- .../completable/CompletableUsing.java | 7 +- .../operators/flowable/FlowableBuffer.java | 25 ++- .../flowable/FlowableBufferBoundary.java | 13 +- .../FlowableBufferBoundarySupplier.java | 24 +-- .../flowable/FlowableBufferExactBoundary.java | 14 +- .../flowable/FlowableBufferTimed.java | 31 ++-- .../operators/flowable/FlowableCollect.java | 10 +- .../flowable/FlowableCollectSingle.java | 12 +- .../flowable/FlowableCombineLatest.java | 4 +- .../operators/flowable/FlowableConcatMap.java | 15 +- .../operators/flowable/FlowableDefer.java | 9 +- .../operators/flowable/FlowableDistinct.java | 11 +- .../FlowableDistinctUntilChanged.java | 4 +- .../flowable/FlowableDoAfterNext.java | 4 +- .../operators/flowable/FlowableDoFinally.java | 4 +- .../operators/flowable/FlowableDoOnEach.java | 4 +- .../operators/flowable/FlowableEmpty.java | 6 +- .../operators/flowable/FlowableError.java | 9 +- .../operators/flowable/FlowableFilter.java | 4 +- .../operators/flowable/FlowableFlatMap.java | 7 +- .../flowable/FlowableFlattenIterable.java | 9 +- .../operators/flowable/FlowableGenerate.java | 7 +- .../operators/flowable/FlowableGroupBy.java | 2 +- .../flowable/FlowableInternalHelper.java | 46 ++--- .../operators/flowable/FlowableJust.java | 6 +- .../operators/flowable/FlowableMap.java | 4 +- .../flowable/FlowableMapNotification.java | 14 +- .../operators/flowable/FlowableObserveOn.java | 4 +- .../flowable/FlowableReduceWithSingle.java | 10 +- .../operators/flowable/FlowableReplay.java | 36 ++-- .../flowable/FlowableScalarXMap.java | 18 +- .../operators/flowable/FlowableScanSeed.java | 9 +- .../operators/flowable/FlowableToList.java | 8 +- .../flowable/FlowableToListSingle.java | 10 +- .../operators/flowable/FlowableUsing.java | 7 +- .../FlowableWindowBoundarySupplier.java | 12 +- .../flowable/FlowableWithLatestFromMany.java | 2 +- .../internal/operators/maybe/MaybeDefer.java | 9 +- .../internal/operators/maybe/MaybeEmpty.java | 6 +- .../operators/maybe/MaybeErrorCallable.java | 13 +- .../maybe/MaybeFlatMapNotification.java | 19 +- .../operators/maybe/MaybeFlatten.java | 2 +- .../operators/maybe/MaybeFromAction.java | 8 +- .../operators/maybe/MaybeFromCallable.java | 5 +- .../operators/maybe/MaybeFromRunnable.java | 7 +- .../internal/operators/maybe/MaybeJust.java | 6 +- .../internal/operators/maybe/MaybeUsing.java | 7 +- .../operators/maybe/MaybeZipArray.java | 2 +- .../operators/maybe/MaybeZipIterable.java | 2 +- .../operators/mixed/ScalarXMapZHelper.java | 34 ++-- .../observable/ObservableBuffer.java | 20 +-- .../observable/ObservableBufferBoundary.java | 13 +- .../ObservableBufferBoundarySupplier.java | 26 +-- .../ObservableBufferExactBoundary.java | 16 +- .../observable/ObservableBufferTimed.java | 31 ++-- .../observable/ObservableCollect.java | 12 +- .../observable/ObservableCollectSingle.java | 10 +- .../observable/ObservableConcatMap.java | 9 +- .../operators/observable/ObservableDefer.java | 11 +- .../observable/ObservableDistinct.java | 11 +- .../ObservableDistinctUntilChanged.java | 2 +- .../observable/ObservableDoAfterNext.java | 2 +- .../observable/ObservableDoFinally.java | 2 +- .../operators/observable/ObservableEmpty.java | 6 +- .../operators/observable/ObservableError.java | 11 +- .../observable/ObservableFilter.java | 2 +- .../observable/ObservableFlatMap.java | 13 +- .../observable/ObservableGenerate.java | 8 +- .../observable/ObservableInternalHelper.java | 50 +++--- .../operators/observable/ObservableJust.java | 6 +- .../operators/observable/ObservableMap.java | 2 +- .../observable/ObservableMapNotification.java | 14 +- .../observable/ObservableObserveOn.java | 2 +- .../ObservableReduceWithSingle.java | 10 +- .../observable/ObservableReplay.java | 10 +- .../observable/ObservableScalarXMap.java | 17 +- .../observable/ObservableScanSeed.java | 12 +- .../observable/ObservableToList.java | 10 +- .../observable/ObservableToListSingle.java | 17 +- .../operators/observable/ObservableUsing.java | 7 +- .../ObservableWindowBoundarySupplier.java | 12 +- .../ObservableWithLatestFromMany.java | 2 +- .../operators/parallel/ParallelCollect.java | 10 +- .../operators/parallel/ParallelReduce.java | 10 +- .../operators/single/SingleDefer.java | 9 +- .../operators/single/SingleError.java | 11 +- .../single/SingleInternalHelper.java | 11 +- .../operators/single/SingleUsing.java | 7 +- .../operators/single/SingleZipArray.java | 2 +- .../operators/single/SingleZipIterable.java | 2 +- .../util/AppendOnlyLinkedArrayList.java | 2 +- .../internal/util/ArrayListSupplier.java | 13 +- .../internal/util/HashMapSupplier.java | 14 +- .../reactivex/observers/BaseTestConsumer.java | 6 +- .../reactivex/parallel/ParallelFlowable.java | 5 +- .../io/reactivex/plugins/RxJavaPlugins.java | 80 ++++----- .../io/reactivex/schedulers/Schedulers.java | 17 +- src/test/java/io/reactivex/TestHelper.java | 4 +- .../completable/CompletableTest.java | 138 ++++++++------- .../flowable/FlowableCollectTest.java | 44 ++--- .../flowable/FlowableMergeTests.java | 6 +- .../reactivex/flowable/FlowableNullTests.java | 159 ++++++++--------- .../io/reactivex/flowable/FlowableTests.java | 12 +- .../internal/functions/FunctionsTest.java | 20 +-- .../completable/CompletableUsingTest.java | 77 ++++----- .../flowable/FlowableBufferTest.java | 148 ++++++++-------- .../operators/flowable/FlowableCacheTest.java | 2 +- .../operators/flowable/FlowableDeferTest.java | 18 +- .../operators/flowable/FlowableDelayTest.java | 28 +-- .../flowable/FlowableDistinctTest.java | 11 +- .../FlowableDoAfterTerminateTest.java | 2 +- .../flowable/FlowableFlatMapTest.java | 14 +- .../flowable/FlowableFlattenIterableTest.java | 2 +- .../flowable/FlowableFromArrayTest.java | 4 +- .../flowable/FlowableFromIterableTest.java | 2 +- .../flowable/FlowableGenerateTest.java | 39 ++--- .../flowable/FlowableGroupByTest.java | 8 +- .../flowable/FlowableGroupJoinTest.java | 2 +- .../flowable/FlowableIgnoreElementsTest.java | 4 +- .../flowable/FlowableMapNotificationTest.java | 22 ++- .../FlowableReduceWithSingleTest.java | 4 +- .../flowable/FlowableRefCountTest.java | 6 +- .../flowable/FlowableReplayTest.java | 20 +-- .../operators/flowable/FlowableRetryTest.java | 22 +-- .../flowable/FlowableScalarXMapTest.java | 16 +- .../operators/flowable/FlowableScanTest.java | 16 +- .../flowable/FlowableThrottleLatestTest.java | 8 +- .../FlowableTimeoutWithSelectorTest.java | 4 +- .../flowable/FlowableToListTest.java | 18 +- .../operators/flowable/FlowableToMapTest.java | 20 +-- .../flowable/FlowableToMultimapTest.java | 36 ++-- .../operators/flowable/FlowableUsingTest.java | 71 ++++---- .../FlowableWindowWithFlowableTest.java | 74 ++++---- ...lowableWindowWithStartEndFlowableTest.java | 4 +- .../operators/maybe/MaybeEmptyTest.java | 8 +- .../operators/maybe/MaybeErrorTest.java | 9 +- .../maybe/MaybeFlatMapNotificationTest.java | 14 +- .../operators/maybe/MaybeFromActionTest.java | 10 +- .../maybe/MaybeFromCallableTest.java | 13 +- .../maybe/MaybeFromRunnableTest.java | 7 +- .../operators/maybe/MaybeHideTest.java | 6 +- .../operators/maybe/MaybeJustTest.java | 8 +- .../operators/maybe/MaybeUsingTest.java | 77 ++++----- .../observable/ObservableBufferTest.java | 148 ++++++++-------- .../observable/ObservableCacheTest.java | 2 +- .../observable/ObservableCollectTest.java | 48 +++--- .../observable/ObservableDeferTest.java | 18 +- .../observable/ObservableDelayTest.java | 16 +- .../observable/ObservableDistinctTest.java | 11 +- .../observable/ObservableFlatMapTest.java | 12 +- .../observable/ObservableFromTest.java | 2 +- .../observable/ObservableGenerateTest.java | 26 +-- .../observable/ObservableGroupJoinTest.java | 2 +- .../ObservableMapNotificationTest.java | 14 +- .../observable/ObservableReduceTest.java | 5 +- .../observable/ObservableRefCountTest.java | 4 +- .../observable/ObservableReplayTest.java | 10 +- .../observable/ObservableRetryTest.java | 22 +-- .../observable/ObservableScalarXMapTest.java | 16 +- .../observable/ObservableScanTest.java | 8 +- .../ObservableThrottleLatestTest.java | 2 +- .../ObservableTimeoutWithSelectorTest.java | 4 +- .../observable/ObservableToListTest.java | 18 +- .../observable/ObservableToMapTest.java | 20 +-- .../observable/ObservableToMultimapTest.java | 36 ++-- .../observable/ObservableUsingTest.java | 63 ++++--- .../ObservableWindowWithObservableTest.java | 66 +++---- ...vableWindowWithStartEndObservableTest.java | 4 +- .../operators/single/SingleDeferTest.java | 7 +- .../operators/single/SingleErrorTest.java | 9 +- .../operators/single/SingleUsingTest.java | 37 ++-- .../schedulers/SchedulerWhenTest.java | 7 +- .../reactivex/internal/util/MiscUtilTest.java | 12 +- .../internal/util/TestingHelper.java | 13 +- .../java/io/reactivex/maybe/MaybeTest.java | 40 ++--- .../observable/ObservableMergeTests.java | 6 +- .../observable/ObservableNullTests.java | 152 ++++++++-------- .../reactivex/observable/ObservableTest.java | 12 +- .../parallel/ParallelCollectTest.java | 25 ++- .../parallel/ParallelFlowableTest.java | 32 ++-- .../parallel/ParallelFromPublisherTest.java | 2 +- .../parallel/ParallelReduceTest.java | 26 +-- .../reactivex/plugins/RxJavaPluginsTest.java | 96 +++++------ .../schedulers/TestSchedulerTest.java | 4 +- .../io/reactivex/single/SingleNullTests.java | 14 +- .../java/io/reactivex/tck/DeferTckTest.java | 7 +- .../io/reactivex/tck/GenerateTckTest.java | 2 +- .../io/reactivex/tck/ReduceWithTckTest.java | 2 +- .../java/io/reactivex/tck/UsingTckTest.java | 2 +- .../ParamValidationCheckerTest.java | 13 +- 221 files changed, 2007 insertions(+), 2034 deletions(-) create mode 100644 src/main/java/io/reactivex/functions/Supplier.java rename src/main/java/io/reactivex/internal/fuseable/{ScalarCallable.java => ScalarSupplier.java} (84%) diff --git a/src/main/java/io/reactivex/Completable.java b/src/main/java/io/reactivex/Completable.java index 79fcc9b432..c8a722f8e5 100644 --- a/src/main/java/io/reactivex/Completable.java +++ b/src/main/java/io/reactivex/Completable.java @@ -350,7 +350,7 @@ public static Completable unsafeCreate(CompletableSource source) { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Completable defer(final Callable completableSupplier) { + public static Completable defer(final Supplier completableSupplier) { ObjectHelper.requireNonNull(completableSupplier, "completableSupplier"); return RxJavaPlugins.onAssembly(new CompletableDefer(completableSupplier)); } @@ -374,7 +374,7 @@ public static Completable defer(final Callable comp @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Completable error(final Callable errorSupplier) { + public static Completable error(final Supplier errorSupplier) { ObjectHelper.requireNonNull(errorSupplier, "errorSupplier is null"); return RxJavaPlugins.onAssembly(new CompletableErrorSupplier(errorSupplier)); } @@ -971,7 +971,7 @@ private static NullPointerException toNpe(Throwable ex) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Completable using(Callable resourceSupplier, + public static Completable using(Supplier resourceSupplier, Function completableFunction, Consumer disposer) { return using(resourceSupplier, completableFunction, disposer, true); @@ -1003,7 +1003,7 @@ public static Completable using(Callable resourceSupplier, @NonNull @SchedulerSupport(SchedulerSupport.NONE) public static Completable using( - final Callable resourceSupplier, + final Supplier resourceSupplier, final Function completableFunction, final Consumer disposer, final boolean eager) { @@ -2688,7 +2688,7 @@ public final Observable toObservable() { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public final Single toSingle(final Callable completionValueSupplier) { + public final Single toSingle(final Supplier completionValueSupplier) { ObjectHelper.requireNonNull(completionValueSupplier, "completionValueSupplier is null"); return RxJavaPlugins.onAssembly(new CompletableToSingle(this, completionValueSupplier, null)); } diff --git a/src/main/java/io/reactivex/Flowable.java b/src/main/java/io/reactivex/Flowable.java index 7dc6d77716..6411e3dd0c 100644 --- a/src/main/java/io/reactivex/Flowable.java +++ b/src/main/java/io/reactivex/Flowable.java @@ -1935,7 +1935,7 @@ public static Flowable create(FlowableOnSubscribe source, Backpressure @NonNull @BackpressureSupport(BackpressureKind.PASS_THROUGH) @SchedulerSupport(SchedulerSupport.NONE) - public static Flowable defer(Callable> supplier) { + public static Flowable defer(Supplier> supplier) { ObjectHelper.requireNonNull(supplier, "supplier is null"); return RxJavaPlugins.onAssembly(new FlowableDefer(supplier)); } @@ -1979,7 +1979,7 @@ public static Flowable empty() { * * * @param supplier - * a Callable factory to return a Throwable for each individual Subscriber + * a Supplier factory to return a Throwable for each individual Subscriber * @param * the type of the items (ostensibly) emitted by the Publisher * @return a Flowable that invokes the {@link Subscriber}'s {@link Subscriber#onError onError} method when @@ -1990,7 +1990,7 @@ public static Flowable empty() { @NonNull @BackpressureSupport(BackpressureKind.PASS_THROUGH) @SchedulerSupport(SchedulerSupport.NONE) - public static Flowable error(Callable supplier) { + public static Flowable error(Supplier supplier) { ObjectHelper.requireNonNull(supplier, "supplier is null"); return RxJavaPlugins.onAssembly(new FlowableError(supplier)); } @@ -2021,7 +2021,7 @@ public static Flowable error(Callable supplier) { @SchedulerSupport(SchedulerSupport.NONE) public static Flowable error(final Throwable throwable) { ObjectHelper.requireNonNull(throwable, "throwable is null"); - return error(Functions.justCallable(throwable)); + return error(Functions.justSupplier(throwable)); } /** @@ -2086,7 +2086,7 @@ public static Flowable fromArray(T... items) { * @param * the type of the item emitted by the Publisher * @return a Flowable whose {@link Subscriber}s' subscriptions trigger an invocation of the given function - * @see #defer(Callable) + * @see #defer(Supplier) * @since 2.0 */ @CheckReturnValue @@ -2379,7 +2379,7 @@ public static Flowable generate(final Consumer> generator) { * * @param the type of the per-Subscriber state * @param the generated value type - * @param initialState the Callable to generate the initial state for each Subscriber + * @param initialState the Supplier to generate the initial state for each Subscriber * @param generator the Consumer called with the current state whenever a particular downstream Subscriber has * requested a value. The callback then should call {@code onNext}, {@code onError} or * {@code onComplete} to signal a value or a terminal event. Signaling multiple {@code onNext} @@ -2390,7 +2390,7 @@ public static Flowable generate(final Consumer> generator) { @NonNull @BackpressureSupport(BackpressureKind.FULL) @SchedulerSupport(SchedulerSupport.NONE) - public static Flowable generate(Callable initialState, final BiConsumer> generator) { + public static Flowable generate(Supplier initialState, final BiConsumer> generator) { ObjectHelper.requireNonNull(generator, "generator is null"); return generate(initialState, FlowableInternalHelper.simpleBiGenerator(generator), Functions.emptyConsumer()); @@ -2412,7 +2412,7 @@ public static Flowable generate(Callable initialState, final BiCons * * @param the type of the per-Subscriber state * @param the generated value type - * @param initialState the Callable to generate the initial state for each Subscriber + * @param initialState the Supplier to generate the initial state for each Subscriber * @param generator the Consumer called with the current state whenever a particular downstream Subscriber has * requested a value. The callback then should call {@code onNext}, {@code onError} or * {@code onComplete} to signal a value or a terminal event. Signaling multiple {@code onNext} @@ -2425,7 +2425,7 @@ public static Flowable generate(Callable initialState, final BiCons @NonNull @BackpressureSupport(BackpressureKind.FULL) @SchedulerSupport(SchedulerSupport.NONE) - public static Flowable generate(Callable initialState, final BiConsumer> generator, + public static Flowable generate(Supplier initialState, final BiConsumer> generator, Consumer disposeState) { ObjectHelper.requireNonNull(generator, "generator is null"); return generate(initialState, FlowableInternalHelper.simpleBiGenerator(generator), disposeState); @@ -2447,7 +2447,7 @@ public static Flowable generate(Callable initialState, final BiCons * * @param the type of the per-Subscriber state * @param the generated value type - * @param initialState the Callable to generate the initial state for each Subscriber + * @param initialState the Supplier to generate the initial state for each Subscriber * @param generator the Function called with the current state whenever a particular downstream Subscriber has * requested a value. The callback then should call {@code onNext}, {@code onError} or * {@code onComplete} to signal a value or a terminal event and should return a (new) state for @@ -2458,7 +2458,7 @@ public static Flowable generate(Callable initialState, final BiCons @CheckReturnValue @BackpressureSupport(BackpressureKind.FULL) @SchedulerSupport(SchedulerSupport.NONE) - public static Flowable generate(Callable initialState, BiFunction, S> generator) { + public static Flowable generate(Supplier initialState, BiFunction, S> generator) { return generate(initialState, generator, Functions.emptyConsumer()); } @@ -2478,7 +2478,7 @@ public static Flowable generate(Callable initialState, BiFunction the type of the per-Subscriber state * @param the generated value type - * @param initialState the Callable to generate the initial state for each Subscriber + * @param initialState the Supplier to generate the initial state for each Subscriber * @param generator the Function called with the current state whenever a particular downstream Subscriber has * requested a value. The callback then should call {@code onNext}, {@code onError} or * {@code onComplete} to signal a value or a terminal event and should return a (new) state for @@ -2492,7 +2492,7 @@ public static Flowable generate(Callable initialState, BiFunction Flowable generate(Callable initialState, BiFunction, S> generator, Consumer disposeState) { + public static Flowable generate(Supplier initialState, BiFunction, S> generator, Consumer disposeState) { ObjectHelper.requireNonNull(initialState, "initialState is null"); ObjectHelper.requireNonNull(generator, "generator is null"); ObjectHelper.requireNonNull(disposeState, "disposeState is null"); @@ -4531,7 +4531,7 @@ public static Flowable unsafeCreate(Publisher onSubscribe) { @CheckReturnValue @BackpressureSupport(BackpressureKind.PASS_THROUGH) @SchedulerSupport(SchedulerSupport.NONE) - public static Flowable using(Callable resourceSupplier, + public static Flowable using(Supplier resourceSupplier, Function> sourceSupplier, Consumer resourceDisposer) { return using(resourceSupplier, sourceSupplier, resourceDisposer, true); } @@ -4571,7 +4571,7 @@ public static Flowable using(Callable resourceSupplier, @NonNull @BackpressureSupport(BackpressureKind.PASS_THROUGH) @SchedulerSupport(SchedulerSupport.NONE) - public static Flowable using(Callable resourceSupplier, + public static Flowable using(Supplier resourceSupplier, Function> sourceSupplier, Consumer resourceDisposer, boolean eager) { ObjectHelper.requireNonNull(resourceSupplier, "resourceSupplier is null"); @@ -6334,7 +6334,7 @@ public final Flowable> buffer(int count) { @BackpressureSupport(BackpressureKind.FULL) @SchedulerSupport(SchedulerSupport.NONE) public final Flowable> buffer(int count, int skip) { - return buffer(count, skip, ArrayListSupplier.asCallable()); + return buffer(count, skip, ArrayListSupplier.asSupplier()); } /** @@ -6372,7 +6372,7 @@ public final Flowable> buffer(int count, int skip) { @NonNull @BackpressureSupport(BackpressureKind.FULL) @SchedulerSupport(SchedulerSupport.NONE) - public final > Flowable buffer(int count, int skip, Callable bufferSupplier) { + public final > Flowable buffer(int count, int skip, Supplier bufferSupplier) { ObjectHelper.verifyPositive(count, "count"); ObjectHelper.verifyPositive(skip, "skip"); ObjectHelper.requireNonNull(bufferSupplier, "bufferSupplier is null"); @@ -6409,7 +6409,7 @@ public final > Flowable buffer(int count, int @CheckReturnValue @BackpressureSupport(BackpressureKind.FULL) @SchedulerSupport(SchedulerSupport.NONE) - public final > Flowable buffer(int count, Callable bufferSupplier) { + public final > Flowable buffer(int count, Supplier bufferSupplier) { return buffer(count, count, bufferSupplier); } @@ -6444,7 +6444,7 @@ public final > Flowable buffer(int count, Cal @BackpressureSupport(BackpressureKind.ERROR) @SchedulerSupport(SchedulerSupport.COMPUTATION) public final Flowable> buffer(long timespan, long timeskip, TimeUnit unit) { - return buffer(timespan, timeskip, unit, Schedulers.computation(), ArrayListSupplier.asCallable()); + return buffer(timespan, timeskip, unit, Schedulers.computation(), ArrayListSupplier.asSupplier()); } /** @@ -6481,7 +6481,7 @@ public final Flowable> buffer(long timespan, long timeskip, TimeUnit uni @BackpressureSupport(BackpressureKind.ERROR) @SchedulerSupport(SchedulerSupport.CUSTOM) public final Flowable> buffer(long timespan, long timeskip, TimeUnit unit, Scheduler scheduler) { - return buffer(timespan, timeskip, unit, scheduler, ArrayListSupplier.asCallable()); + return buffer(timespan, timeskip, unit, scheduler, ArrayListSupplier.asSupplier()); } /** @@ -6523,7 +6523,7 @@ public final Flowable> buffer(long timespan, long timeskip, TimeUnit uni @BackpressureSupport(BackpressureKind.ERROR) @SchedulerSupport(SchedulerSupport.CUSTOM) public final > Flowable buffer(long timespan, long timeskip, TimeUnit unit, - Scheduler scheduler, Callable bufferSupplier) { + Scheduler scheduler, Supplier bufferSupplier) { ObjectHelper.requireNonNull(unit, "unit is null"); ObjectHelper.requireNonNull(scheduler, "scheduler is null"); ObjectHelper.requireNonNull(bufferSupplier, "bufferSupplier is null"); @@ -6635,7 +6635,7 @@ public final Flowable> buffer(long timespan, TimeUnit unit, int count) { @BackpressureSupport(BackpressureKind.ERROR) @SchedulerSupport(SchedulerSupport.CUSTOM) public final Flowable> buffer(long timespan, TimeUnit unit, Scheduler scheduler, int count) { - return buffer(timespan, unit, scheduler, count, ArrayListSupplier.asCallable(), false); + return buffer(timespan, unit, scheduler, count, ArrayListSupplier.asSupplier(), false); } /** @@ -6682,7 +6682,7 @@ public final Flowable> buffer(long timespan, TimeUnit unit, Scheduler sc public final > Flowable buffer( long timespan, TimeUnit unit, Scheduler scheduler, int count, - Callable bufferSupplier, + Supplier bufferSupplier, boolean restartTimerOnMaxSize) { ObjectHelper.requireNonNull(unit, "unit is null"); ObjectHelper.requireNonNull(scheduler, "scheduler is null"); @@ -6723,7 +6723,7 @@ public final > Flowable buffer( @BackpressureSupport(BackpressureKind.ERROR) @SchedulerSupport(SchedulerSupport.CUSTOM) public final Flowable> buffer(long timespan, TimeUnit unit, Scheduler scheduler) { - return buffer(timespan, unit, scheduler, Integer.MAX_VALUE, ArrayListSupplier.asCallable(), false); + return buffer(timespan, unit, scheduler, Integer.MAX_VALUE, ArrayListSupplier.asSupplier(), false); } /** @@ -6759,7 +6759,7 @@ public final Flowable> buffer(long timespan, TimeUnit unit, Scheduler sc public final Flowable> buffer( Flowable openingIndicator, Function> closingIndicator) { - return buffer(openingIndicator, closingIndicator, ArrayListSupplier.asCallable()); + return buffer(openingIndicator, closingIndicator, ArrayListSupplier.asSupplier()); } /** @@ -6799,7 +6799,7 @@ public final Flowable> buffer( public final > Flowable buffer( Flowable openingIndicator, Function> closingIndicator, - Callable bufferSupplier) { + Supplier bufferSupplier) { ObjectHelper.requireNonNull(openingIndicator, "openingIndicator is null"); ObjectHelper.requireNonNull(closingIndicator, "closingIndicator is null"); ObjectHelper.requireNonNull(bufferSupplier, "bufferSupplier is null"); @@ -6837,7 +6837,7 @@ public final > Flowable b @BackpressureSupport(BackpressureKind.ERROR) @SchedulerSupport(SchedulerSupport.NONE) public final Flowable> buffer(Publisher boundaryIndicator) { - return buffer(boundaryIndicator, ArrayListSupplier.asCallable()); + return buffer(boundaryIndicator, ArrayListSupplier.asSupplier()); } /** @@ -6911,7 +6911,7 @@ public final Flowable> buffer(Publisher boundaryIndicator, final @CheckReturnValue @BackpressureSupport(BackpressureKind.ERROR) @SchedulerSupport(SchedulerSupport.NONE) - public final > Flowable buffer(Publisher boundaryIndicator, Callable bufferSupplier) { + public final > Flowable buffer(Publisher boundaryIndicator, Supplier bufferSupplier) { ObjectHelper.requireNonNull(boundaryIndicator, "boundaryIndicator is null"); ObjectHelper.requireNonNull(bufferSupplier, "bufferSupplier is null"); return RxJavaPlugins.onAssembly(new FlowableBufferExactBoundary(this, boundaryIndicator, bufferSupplier)); @@ -6936,7 +6936,7 @@ public final > Flowable buffer(Publisher the value type of the boundary-providing Publisher * @param boundaryIndicatorSupplier - * a {@link Callable} that produces a Publisher that governs the boundary between buffers. + * a {@link Supplier} that produces a Publisher that governs the boundary between buffers. * Whenever the supplied {@code Publisher} emits an item, {@code buffer} emits the current buffer and * begins to fill a new one * @return a Flowable that emits a connected, non-overlapping buffer of items from the source Publisher @@ -6946,8 +6946,8 @@ public final > Flowable buffer(Publisher Flowable> buffer(Callable> boundaryIndicatorSupplier) { - return buffer(boundaryIndicatorSupplier, ArrayListSupplier.asCallable()); + public final Flowable> buffer(Supplier> boundaryIndicatorSupplier) { + return buffer(boundaryIndicatorSupplier, ArrayListSupplier.asSupplier()); } /** @@ -6983,8 +6983,8 @@ public final Flowable> buffer(Callable> bound @CheckReturnValue @BackpressureSupport(BackpressureKind.ERROR) @SchedulerSupport(SchedulerSupport.NONE) - public final > Flowable buffer(Callable> boundaryIndicatorSupplier, - Callable bufferSupplier) { + public final > Flowable buffer(Supplier> boundaryIndicatorSupplier, + Supplier bufferSupplier) { ObjectHelper.requireNonNull(boundaryIndicatorSupplier, "boundaryIndicatorSupplier is null"); ObjectHelper.requireNonNull(bufferSupplier, "bufferSupplier is null"); return RxJavaPlugins.onAssembly(new FlowableBufferBoundarySupplier(this, boundaryIndicatorSupplier, bufferSupplier)); @@ -7174,7 +7174,7 @@ public final Flowable cast(final Class clazz) { @NonNull @BackpressureSupport(BackpressureKind.UNBOUNDED_IN) @SchedulerSupport(SchedulerSupport.NONE) - public final Single collect(Callable initialItemSupplier, BiConsumer collector) { + public final Single collect(Supplier initialItemSupplier, BiConsumer collector) { ObjectHelper.requireNonNull(initialItemSupplier, "initialItemSupplier is null"); ObjectHelper.requireNonNull(collector, "collector is null"); return RxJavaPlugins.onAssembly(new FlowableCollectSingle(this, initialItemSupplier, collector)); @@ -7215,7 +7215,7 @@ public final Single collect(Callable initialItemSupplier, Bi @SchedulerSupport(SchedulerSupport.NONE) public final Single collectInto(final U initialItem, BiConsumer collector) { ObjectHelper.requireNonNull(initialItem, "initialItem is null"); - return collect(Functions.justCallable(initialItem), collector); + return collect(Functions.justSupplier(initialItem), collector); } /** @@ -7314,9 +7314,9 @@ public final Flowable concatMap(Function Flowable concatMap(Function> mapper, int prefetch) { ObjectHelper.requireNonNull(mapper, "mapper is null"); ObjectHelper.verifyPositive(prefetch, "prefetch"); - if (this instanceof ScalarCallable) { + if (this instanceof ScalarSupplier) { @SuppressWarnings("unchecked") - T v = ((ScalarCallable)this).call(); + T v = ((ScalarSupplier)this).get(); if (v == null) { return empty(); } @@ -7551,9 +7551,9 @@ public final Flowable concatMapDelayError(Function)this).call(); + T v = ((ScalarSupplier)this).get(); if (v == null) { return empty(); } @@ -8836,7 +8836,7 @@ public final Flowable dematerialize(Function> * to {@code OutOfMemoryError}. *

* Customizing the retention policy can happen only by providing a custom {@link java.util.Collection} implementation - * to the {@link #distinct(Function, Callable)} overload. + * to the {@link #distinct(Function, Supplier)} overload. *

*
Backpressure:
*
The operator doesn't interfere with backpressure which is determined by the source {@code Publisher}'s @@ -8849,7 +8849,7 @@ public final Flowable dematerialize(Function> * each other * @see ReactiveX operators documentation: Distinct * @see #distinct(Function) - * @see #distinct(Function, Callable) + * @see #distinct(Function, Supplier) */ @SuppressWarnings({ "rawtypes", "unchecked" }) @CheckReturnValue @@ -8878,7 +8878,7 @@ public final Flowable distinct() { * to {@code OutOfMemoryError}. *

* Customizing the retention policy can happen only by providing a custom {@link java.util.Collection} implementation - * to the {@link #distinct(Function, Callable)} overload. + * to the {@link #distinct(Function, Supplier)} overload. *

*
Backpressure:
*
The operator doesn't interfere with backpressure which is determined by the source {@code Publisher}'s @@ -8893,7 +8893,7 @@ public final Flowable distinct() { * is distinct from another one or not * @return a Flowable that emits those items emitted by the source Publisher that have distinct keys * @see ReactiveX operators documentation: Distinct - * @see #distinct(Function, Callable) + * @see #distinct(Function, Supplier) */ @CheckReturnValue @BackpressureSupport(BackpressureKind.FULL) @@ -8933,7 +8933,7 @@ public final Flowable distinct(Function keySelector) { @BackpressureSupport(BackpressureKind.FULL) @SchedulerSupport(SchedulerSupport.NONE) public final Flowable distinct(Function keySelector, - Callable> collectionSupplier) { + Supplier> collectionSupplier) { ObjectHelper.requireNonNull(keySelector, "keySelector is null"); ObjectHelper.requireNonNull(collectionSupplier, "collectionSupplier is null"); return RxJavaPlugins.onAssembly(new FlowableDistinct(this, keySelector, collectionSupplier)); @@ -9856,9 +9856,9 @@ public final Flowable flatMap(Function)this).call(); + T v = ((ScalarSupplier)this).get(); if (v == null) { return empty(); } @@ -9903,7 +9903,7 @@ public final Flowable flatMap(Function Flowable flatMap( Function> onNextMapper, Function> onErrorMapper, - Callable> onCompleteSupplier) { + Supplier> onCompleteSupplier) { ObjectHelper.requireNonNull(onNextMapper, "onNextMapper is null"); ObjectHelper.requireNonNull(onErrorMapper, "onErrorMapper is null"); ObjectHelper.requireNonNull(onCompleteSupplier, "onCompleteSupplier is null"); @@ -9950,7 +9950,7 @@ public final Flowable flatMap( public final Flowable flatMap( Function> onNextMapper, Function> onErrorMapper, - Callable> onCompleteSupplier, + Supplier> onCompleteSupplier, int maxConcurrency) { ObjectHelper.requireNonNull(onNextMapper, "onNextMapper is null"); ObjectHelper.requireNonNull(onErrorMapper, "onErrorMapper is null"); @@ -12594,7 +12594,7 @@ public final Maybe reduce(BiFunction reducer) { *

* Note that the {@code seed} is shared among all subscribers to the resulting Publisher * and may cause problems if it is mutable. To make sure each subscriber gets its own value, defer - * the application of this operator via {@link #defer(Callable)}: + * the application of this operator via {@link #defer(Supplier)}: *


      * Publisher<T> source = ...
      * Single.defer(() -> source.reduce(new ArrayList<>(), (list, item) -> list.add(item)));
@@ -12631,7 +12631,7 @@ public final Maybe reduce(BiFunction reducer) {
      *         items emitted by the source Publisher
      * @see ReactiveX operators documentation: Reduce
      * @see Wikipedia: Fold (higher-order function)
-     * @see #reduceWith(Callable, BiFunction)
+     * @see #reduceWith(Supplier, BiFunction)
      */
     @CheckReturnValue
     @NonNull
@@ -12669,7 +12669,7 @@ public final  Single reduce(R seed, BiFunction reducer) {
      *
      * @param  the accumulator and output value type
      * @param seedSupplier
-     *            the Callable that provides the initial (seed) accumulator value for each individual Subscriber
+     *            the Supplier that provides the initial (seed) accumulator value for each individual Subscriber
      * @param reducer
      *            an accumulator function to be invoked on each item emitted by the source Publisher, the
      *            result of which will be used in the next accumulator call
@@ -12682,7 +12682,7 @@ public final  Single reduce(R seed, BiFunction reducer) {
     @NonNull
     @BackpressureSupport(BackpressureKind.UNBOUNDED_IN)
     @SchedulerSupport(SchedulerSupport.NONE)
-    public final  Single reduceWith(Callable seedSupplier, BiFunction reducer) {
+    public final  Single reduceWith(Supplier seedSupplier, BiFunction reducer) {
         ObjectHelper.requireNonNull(seedSupplier, "seedSupplier is null");
         ObjectHelper.requireNonNull(reducer, "reducer is null");
         return RxJavaPlugins.onAssembly(new FlowableReduceWithSingle(this, seedSupplier, reducer));
@@ -12862,7 +12862,7 @@ public final ConnectableFlowable replay() {
     @SchedulerSupport(SchedulerSupport.NONE)
     public final  Flowable replay(Function, ? extends Publisher> selector) {
         ObjectHelper.requireNonNull(selector, "selector is null");
-        return FlowableReplay.multicastSelector(FlowableInternalHelper.replayCallable(this), selector);
+        return FlowableReplay.multicastSelector(FlowableInternalHelper.replaySupplier(this), selector);
     }
 
     /**
@@ -12902,7 +12902,7 @@ public final  Flowable replay(Function, ? extends Publ
     public final  Flowable replay(Function, ? extends Publisher> selector, final int bufferSize) {
         ObjectHelper.requireNonNull(selector, "selector is null");
         ObjectHelper.verifyPositive(bufferSize, "bufferSize");
-        return FlowableReplay.multicastSelector(FlowableInternalHelper.replayCallable(this, bufferSize), selector);
+        return FlowableReplay.multicastSelector(FlowableInternalHelper.replaySupplier(this, bufferSize), selector);
     }
 
     /**
@@ -12996,7 +12996,7 @@ public final  Flowable replay(Function, ? extends Publ
         ObjectHelper.verifyPositive(bufferSize, "bufferSize");
         ObjectHelper.requireNonNull(scheduler, "scheduler is null");
         return FlowableReplay.multicastSelector(
-                FlowableInternalHelper.replayCallable(this, bufferSize, time, unit, scheduler), selector);
+                FlowableInternalHelper.replaySupplier(this, bufferSize, time, unit, scheduler), selector);
     }
 
     /**
@@ -13039,7 +13039,7 @@ public final  Flowable replay(final Function, ? extend
         ObjectHelper.requireNonNull(selector, "selector is null");
         ObjectHelper.requireNonNull(scheduler, "scheduler is null");
         ObjectHelper.verifyPositive(bufferSize, "bufferSize");
-        return FlowableReplay.multicastSelector(FlowableInternalHelper.replayCallable(this, bufferSize),
+        return FlowableReplay.multicastSelector(FlowableInternalHelper.replaySupplier(this, bufferSize),
                 FlowableInternalHelper.replayFunction(selector, scheduler)
         );
     }
@@ -13119,7 +13119,7 @@ public final  Flowable replay(Function, ? extends Publ
         ObjectHelper.requireNonNull(selector, "selector is null");
         ObjectHelper.requireNonNull(unit, "unit is null");
         ObjectHelper.requireNonNull(scheduler, "scheduler is null");
-        return FlowableReplay.multicastSelector(FlowableInternalHelper.replayCallable(this, time, unit, scheduler), selector);
+        return FlowableReplay.multicastSelector(FlowableInternalHelper.replaySupplier(this, time, unit, scheduler), selector);
     }
 
     /**
@@ -13155,7 +13155,7 @@ public final  Flowable replay(Function, ? extends Publ
     public final  Flowable replay(final Function, ? extends Publisher> selector, final Scheduler scheduler) {
         ObjectHelper.requireNonNull(selector, "selector is null");
         ObjectHelper.requireNonNull(scheduler, "scheduler is null");
-        return FlowableReplay.multicastSelector(FlowableInternalHelper.replayCallable(this),
+        return FlowableReplay.multicastSelector(FlowableInternalHelper.replaySupplier(this),
                 FlowableInternalHelper.replayFunction(selector, scheduler));
     }
 
@@ -13938,7 +13938,7 @@ public final Flowable scan(BiFunction accumulator) {
      * 

* Note that the {@code initialValue} is shared among all subscribers to the resulting Publisher * and may cause problems if it is mutable. To make sure each subscriber gets its own value, defer - * the application of this operator via {@link #defer(Callable)}: + * the application of this operator via {@link #defer(Supplier)}: *


      * Publisher<T> source = ...
      * Flowable.defer(() -> source.scan(new ArrayList<>(), (list, item) -> list.add(item)));
@@ -13974,7 +13974,7 @@ public final Flowable scan(BiFunction accumulator) {
     @SchedulerSupport(SchedulerSupport.NONE)
     public final  Flowable scan(final R initialValue, BiFunction accumulator) {
         ObjectHelper.requireNonNull(initialValue, "initialValue is null");
-        return scanWith(Functions.justCallable(initialValue), accumulator);
+        return scanWith(Functions.justSupplier(initialValue), accumulator);
     }
 
     /**
@@ -13999,7 +13999,7 @@ public final  Flowable scan(final R initialValue, BiFunction the initial, accumulator and result type
      * @param seedSupplier
-     *            a Callable that returns the initial (seed) accumulator item for each individual Subscriber
+     *            a Supplier that returns the initial (seed) accumulator item for each individual Subscriber
      * @param accumulator
      *            an accumulator function to be invoked on each item emitted by the source Publisher, whose
      *            result will be emitted to {@link Subscriber}s via {@link Subscriber#onNext onNext} and used in the
@@ -14012,7 +14012,7 @@ public final  Flowable scan(final R initialValue, BiFunction Flowable scanWith(Callable seedSupplier, BiFunction accumulator) {
+    public final  Flowable scanWith(Supplier seedSupplier, BiFunction accumulator) {
         ObjectHelper.requireNonNull(seedSupplier, "seedSupplier is null");
         ObjectHelper.requireNonNull(accumulator, "accumulator is null");
         return RxJavaPlugins.onAssembly(new FlowableScanSeed(this, seedSupplier, accumulator));
@@ -15314,9 +15314,9 @@ public final  Flowable switchMapDelayError(Function Flowable switchMap0(Function> mapper, int bufferSize, boolean delayError) {
         ObjectHelper.requireNonNull(mapper, "mapper is null");
         ObjectHelper.verifyPositive(bufferSize, "bufferSize");
-        if (this instanceof ScalarCallable) {
+        if (this instanceof ScalarSupplier) {
             @SuppressWarnings("unchecked")
-            T v = ((ScalarCallable)this).call();
+            T v = ((ScalarSupplier)this).get();
             if (v == null) {
                 return empty();
             }
@@ -16990,7 +16990,7 @@ public final Single> toList(final int capacityHint) {
      *
      * @param  the subclass of a collection of Ts
      * @param collectionSupplier
-     *               the Callable returning the collection (for each individual Subscriber) to be filled in
+     *               the Supplier returning the collection (for each individual Subscriber) to be filled in
      * @return a Single that emits a single item: a List containing all of the items emitted by the source
      *         Publisher
      * @see ReactiveX operators documentation: To
@@ -16998,7 +16998,7 @@ public final Single> toList(final int capacityHint) {
     @CheckReturnValue
     @BackpressureSupport(BackpressureKind.UNBOUNDED_IN)
     @SchedulerSupport(SchedulerSupport.NONE)
-    public final > Single toList(Callable collectionSupplier) {
+    public final > Single toList(Supplier collectionSupplier) {
         ObjectHelper.requireNonNull(collectionSupplier, "collectionSupplier is null");
         return RxJavaPlugins.onAssembly(new FlowableToListSingle(this, collectionSupplier));
     }
@@ -17035,7 +17035,7 @@ public final > Single toList(Callable coll
     @SchedulerSupport(SchedulerSupport.NONE)
     public final  Single> toMap(final Function keySelector) {
         ObjectHelper.requireNonNull(keySelector, "keySelector is null");
-        return collect(HashMapSupplier.asCallable(), Functions.toMapKeySelector(keySelector));
+        return collect(HashMapSupplier.asSupplier(), Functions.toMapKeySelector(keySelector));
     }
 
     /**
@@ -17075,7 +17075,7 @@ public final  Single> toMap(final Function
     public final  Single> toMap(final Function keySelector, final Function valueSelector) {
         ObjectHelper.requireNonNull(keySelector, "keySelector is null");
         ObjectHelper.requireNonNull(valueSelector, "valueSelector is null");
-        return collect(HashMapSupplier.asCallable(), Functions.toMapKeyValueSelector(keySelector, valueSelector));
+        return collect(HashMapSupplier.asSupplier(), Functions.toMapKeyValueSelector(keySelector, valueSelector));
     }
 
     /**
@@ -17113,7 +17113,7 @@ public final  Single> toMap(final Function Single> toMap(final Function keySelector,
             final Function valueSelector,
-            final Callable> mapSupplier) {
+            final Supplier> mapSupplier) {
         ObjectHelper.requireNonNull(keySelector, "keySelector is null");
         ObjectHelper.requireNonNull(valueSelector, "valueSelector is null");
         return collect(mapSupplier, Functions.toMapKeyValueSelector(keySelector, valueSelector));
@@ -17147,7 +17147,7 @@ public final  Single> toMap(final Function Single>> toMultimap(Function keySelector) {
         Function valueSelector = Functions.identity();
-        Callable>> mapSupplier = HashMapSupplier.asCallable();
+        Supplier>> mapSupplier = HashMapSupplier.asSupplier();
         Function> collectionFactory = ArrayListSupplier.asFunction();
         return toMultimap(keySelector, valueSelector, mapSupplier, collectionFactory);
     }
@@ -17184,7 +17184,7 @@ public final  Single>> toMultimap(Function Single>> toMultimap(Function keySelector, Function valueSelector) {
-        Callable>> mapSupplier = HashMapSupplier.asCallable();
+        Supplier>> mapSupplier = HashMapSupplier.asSupplier();
         Function> collectionFactory = ArrayListSupplier.asFunction();
         return toMultimap(keySelector, valueSelector, mapSupplier, collectionFactory);
     }
@@ -17228,7 +17228,7 @@ public final  Single>> toMultimap(Function Single>> toMultimap(
             final Function keySelector,
             final Function valueSelector,
-            final Callable>> mapSupplier,
+            final Supplier>> mapSupplier,
             final Function> collectionFactory) {
         ObjectHelper.requireNonNull(keySelector, "keySelector is null");
         ObjectHelper.requireNonNull(valueSelector, "valueSelector is null");
@@ -17273,7 +17273,7 @@ public final  Single>> toMultimap(
     public final  Single>> toMultimap(
             Function keySelector,
             Function valueSelector,
-            Callable>> mapSupplier
+            Supplier>> mapSupplier
             ) {
         return toMultimap(keySelector, valueSelector, mapSupplier, ArrayListSupplier.asFunction());
     }
@@ -18119,7 +18119,7 @@ public final  Flowable> window(
      *
      * @param  the element type of the boundary Publisher
      * @param boundaryIndicatorSupplier
-     *            a {@link Callable} that returns a {@code Publisher} that governs the boundary between windows.
+     *            a {@link Supplier} that returns a {@code Publisher} that governs the boundary between windows.
      *            When the source {@code Publisher} emits an item, {@code window} emits the current window and begins
      *            a new one.
      * @return a Flowable that emits connected, non-overlapping windows of items from the source Publisher
@@ -18129,7 +18129,7 @@ public final  Flowable> window(
     @CheckReturnValue
     @BackpressureSupport(BackpressureKind.ERROR)
     @SchedulerSupport(SchedulerSupport.NONE)
-    public final  Flowable> window(Callable> boundaryIndicatorSupplier) {
+    public final  Flowable> window(Supplier> boundaryIndicatorSupplier) {
         return window(boundaryIndicatorSupplier, bufferSize());
     }
 
@@ -18152,7 +18152,7 @@ public final  Flowable> window(Callable> b
      *
      * @param  the element type of the boundary Publisher
      * @param boundaryIndicatorSupplier
-     *            a {@link Callable} that returns a {@code Publisher} that governs the boundary between windows.
+     *            a {@link Supplier} that returns a {@code Publisher} that governs the boundary between windows.
      *            When the source {@code Publisher} emits an item, {@code window} emits the current window and begins
      *            a new one.
      * @param bufferSize
@@ -18165,7 +18165,7 @@ public final  Flowable> window(Callable> b
     @NonNull
     @BackpressureSupport(BackpressureKind.ERROR)
     @SchedulerSupport(SchedulerSupport.NONE)
-    public final  Flowable> window(Callable> boundaryIndicatorSupplier, int bufferSize) {
+    public final  Flowable> window(Supplier> boundaryIndicatorSupplier, int bufferSize) {
         ObjectHelper.requireNonNull(boundaryIndicatorSupplier, "boundaryIndicatorSupplier is null");
         ObjectHelper.verifyPositive(bufferSize, "bufferSize");
         return RxJavaPlugins.onAssembly(new FlowableWindowBoundarySupplier(this, boundaryIndicatorSupplier, bufferSize));
diff --git a/src/main/java/io/reactivex/Maybe.java b/src/main/java/io/reactivex/Maybe.java
index aecb501348..762cf6535b 100644
--- a/src/main/java/io/reactivex/Maybe.java
+++ b/src/main/java/io/reactivex/Maybe.java
@@ -573,21 +573,21 @@ public static  Maybe create(MaybeOnSubscribe onSubscribe) {
     }
 
     /**
-     * Calls a Callable for each individual MaybeObserver to return the actual MaybeSource source to
+     * Calls a Supplier for each individual MaybeObserver to return the actual MaybeSource source to
      * be subscribed to.
      * 
*
Scheduler:
*
{@code defer} does not operate by default on a particular {@link Scheduler}.
*
* @param the value type - * @param maybeSupplier the Callable that is called for each individual MaybeObserver and + * @param maybeSupplier the Supplier that is called for each individual MaybeObserver and * returns a MaybeSource instance to subscribe to * @return the new Maybe instance */ @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Maybe defer(final Callable> maybeSupplier) { + public static Maybe defer(final Supplier> maybeSupplier) { ObjectHelper.requireNonNull(maybeSupplier, "maybeSupplier is null"); return RxJavaPlugins.onAssembly(new MaybeDefer(maybeSupplier)); } @@ -648,7 +648,7 @@ public static Maybe error(Throwable exception) { *
* * @param supplier - * a Callable factory to return a Throwable for each individual MaybeObserver + * a Supplier factory to return a Throwable for each individual MaybeObserver * @param * the type of the items (ostensibly) emitted by the Maybe * @return a Maybe that invokes the {@link MaybeObserver}'s {@link MaybeObserver#onError onError} method when @@ -658,7 +658,7 @@ public static Maybe error(Throwable exception) { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Maybe error(Callable supplier) { + public static Maybe error(Supplier supplier) { ObjectHelper.requireNonNull(supplier, "errorSupplier is null"); return RxJavaPlugins.onAssembly(new MaybeErrorCallable(supplier)); } @@ -1689,7 +1689,7 @@ public static Maybe unsafeCreate(MaybeSource onSubscribe) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Maybe using(Callable resourceSupplier, + public static Maybe using(Supplier resourceSupplier, Function> sourceSupplier, Consumer resourceDisposer) { return using(resourceSupplier, sourceSupplier, resourceDisposer, true); @@ -1725,7 +1725,7 @@ public static Maybe using(Callable resourceSupplier, @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Maybe using(Callable resourceSupplier, + public static Maybe using(Supplier resourceSupplier, Function> sourceSupplier, Consumer resourceDisposer, boolean eager) { ObjectHelper.requireNonNull(resourceSupplier, "resourceSupplier is null"); @@ -3022,7 +3022,7 @@ public final Maybe flatMap(Function Maybe flatMap( Function> onSuccessMapper, Function> onErrorMapper, - Callable> onCompleteSupplier) { + Supplier> onCompleteSupplier) { ObjectHelper.requireNonNull(onSuccessMapper, "onSuccessMapper is null"); ObjectHelper.requireNonNull(onErrorMapper, "onErrorMapper is null"); ObjectHelper.requireNonNull(onCompleteSupplier, "onCompleteSupplier is null"); diff --git a/src/main/java/io/reactivex/Observable.java b/src/main/java/io/reactivex/Observable.java index 20b829ad2e..1b98b2328a 100644 --- a/src/main/java/io/reactivex/Observable.java +++ b/src/main/java/io/reactivex/Observable.java @@ -23,7 +23,7 @@ import io.reactivex.exceptions.Exceptions; import io.reactivex.functions.*; import io.reactivex.internal.functions.*; -import io.reactivex.internal.fuseable.ScalarCallable; +import io.reactivex.internal.fuseable.ScalarSupplier; import io.reactivex.internal.observers.*; import io.reactivex.internal.operators.flowable.*; import io.reactivex.internal.operators.mixed.*; @@ -1662,7 +1662,7 @@ public static Observable create(ObservableOnSubscribe source) { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable defer(Callable> supplier) { + public static Observable defer(Supplier> supplier) { ObjectHelper.requireNonNull(supplier, "supplier is null"); return RxJavaPlugins.onAssembly(new ObservableDefer(supplier)); } @@ -1701,7 +1701,7 @@ public static Observable empty() { *
* * @param errorSupplier - * a Callable factory to return a Throwable for each individual Observer + * a Supplier factory to return a Throwable for each individual Observer * @param * the type of the items (ostensibly) emitted by the ObservableSource * @return an Observable that invokes the {@link Observer}'s {@link Observer#onError onError} method when @@ -1711,7 +1711,7 @@ public static Observable empty() { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable error(Callable errorSupplier) { + public static Observable error(Supplier errorSupplier) { ObjectHelper.requireNonNull(errorSupplier, "errorSupplier is null"); return RxJavaPlugins.onAssembly(new ObservableError(errorSupplier)); } @@ -1739,7 +1739,7 @@ public static Observable error(Callable errorSupplie @SchedulerSupport(SchedulerSupport.NONE) public static Observable error(final Throwable exception) { ObjectHelper.requireNonNull(exception, "exception is null"); - return error(Functions.justCallable(exception)); + return error(Functions.justSupplier(exception)); } /** @@ -1797,7 +1797,7 @@ public static Observable fromArray(T... items) { * @param * the type of the item emitted by the ObservableSource * @return an Observable whose {@link Observer}s' subscriptions trigger an invocation of the given function - * @see #defer(Callable) + * @see #defer(Supplier) * @since 2.0 */ @CheckReturnValue @@ -2048,7 +2048,7 @@ public static Observable fromPublisher(Publisher publisher) public static Observable generate(final Consumer> generator) { ObjectHelper.requireNonNull(generator, "generator is null"); return generate(Functions.nullSupplier(), - ObservableInternalHelper.simpleGenerator(generator), Functions.emptyConsumer()); + ObservableInternalHelper.simpleGenerator(generator), Functions.emptyConsumer()); } /** @@ -2067,7 +2067,7 @@ public static Observable generate(final Consumer> generator) { * * @param the type of the per-Observer state * @param the generated value type - * @param initialState the Callable to generate the initial state for each Observer + * @param initialState the Supplier to generate the initial state for each Observer * @param generator the Consumer called with the current state whenever a particular downstream Observer has * requested a value. The callback then should call {@code onNext}, {@code onError} or * {@code onComplete} to signal a value or a terminal event. Signalling multiple {@code onNext} @@ -2077,7 +2077,7 @@ public static Observable generate(final Consumer> generator) { @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable generate(Callable initialState, final BiConsumer> generator) { + public static Observable generate(Supplier initialState, final BiConsumer> generator) { ObjectHelper.requireNonNull(generator, "generator is null"); return generate(initialState, ObservableInternalHelper.simpleBiGenerator(generator), Functions.emptyConsumer()); } @@ -2098,7 +2098,7 @@ public static Observable generate(Callable initialState, final BiCo * * @param the type of the per-Observer state * @param the generated value type - * @param initialState the Callable to generate the initial state for each Observer + * @param initialState the Supplier to generate the initial state for each Observer * @param generator the Consumer called with the current state whenever a particular downstream Observer has * requested a value. The callback then should call {@code onNext}, {@code onError} or * {@code onComplete} to signal a value or a terminal event. Signalling multiple {@code onNext} @@ -2111,7 +2111,7 @@ public static Observable generate(Callable initialState, final BiCo @NonNull @SchedulerSupport(SchedulerSupport.NONE) public static Observable generate( - final Callable initialState, + final Supplier initialState, final BiConsumer> generator, Consumer disposeState) { ObjectHelper.requireNonNull(generator, "generator is null"); @@ -2134,7 +2134,7 @@ public static Observable generate( * * @param the type of the per-Observer state * @param the generated value type - * @param initialState the Callable to generate the initial state for each Observer + * @param initialState the Supplier to generate the initial state for each Observer * @param generator the Function called with the current state whenever a particular downstream Observer has * requested a value. The callback then should call {@code onNext}, {@code onError} or * {@code onComplete} to signal a value or a terminal event and should return a (new) state for @@ -2144,7 +2144,7 @@ public static Observable generate( */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Observable generate(Callable initialState, BiFunction, S> generator) { + public static Observable generate(Supplier initialState, BiFunction, S> generator) { return generate(initialState, generator, Functions.emptyConsumer()); } @@ -2164,7 +2164,7 @@ public static Observable generate(Callable initialState, BiFunction * * @param the type of the per-Observer state * @param the generated value type - * @param initialState the Callable to generate the initial state for each Observer + * @param initialState the Supplier to generate the initial state for each Observer * @param generator the Function called with the current state whenever a particular downstream Observer has * requested a value. The callback then should call {@code onNext}, {@code onError} or * {@code onComplete} to signal a value or a terminal event and should return a (new) state for @@ -2177,7 +2177,7 @@ public static Observable generate(Callable initialState, BiFunction @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Observable generate(Callable initialState, BiFunction, S> generator, + public static Observable generate(Supplier initialState, BiFunction, S> generator, Consumer disposeState) { ObjectHelper.requireNonNull(initialState, "initialState is null"); ObjectHelper.requireNonNull(generator, "generator is null"); @@ -4025,7 +4025,7 @@ public static Observable unsafeCreate(ObservableSource onSubscribe) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Observable using(Callable resourceSupplier, Function> sourceSupplier, Consumer disposer) { + public static Observable using(Supplier resourceSupplier, Function> sourceSupplier, Consumer disposer) { return using(resourceSupplier, sourceSupplier, disposer, true); } @@ -4059,7 +4059,7 @@ public static Observable using(Callable resourceSupplier, */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Observable using(Callable resourceSupplier, Function> sourceSupplier, Consumer disposer, boolean eager) { + public static Observable using(Supplier resourceSupplier, Function> sourceSupplier, Consumer disposer, boolean eager) { ObjectHelper.requireNonNull(resourceSupplier, "resourceSupplier is null"); ObjectHelper.requireNonNull(sourceSupplier, "sourceSupplier is null"); ObjectHelper.requireNonNull(disposer, "disposer is null"); @@ -5603,7 +5603,7 @@ public final Observable> buffer(int count) { @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final Observable> buffer(int count, int skip) { - return buffer(count, skip, ArrayListSupplier.asCallable()); + return buffer(count, skip, ArrayListSupplier.asSupplier()); } /** @@ -5635,7 +5635,7 @@ public final Observable> buffer(int count, int skip) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final > Observable buffer(int count, int skip, Callable bufferSupplier) { + public final > Observable buffer(int count, int skip, Supplier bufferSupplier) { ObjectHelper.verifyPositive(count, "count"); ObjectHelper.verifyPositive(skip, "skip"); ObjectHelper.requireNonNull(bufferSupplier, "bufferSupplier is null"); @@ -5667,7 +5667,7 @@ public final > Observable buffer(int count, i */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final > Observable buffer(int count, Callable bufferSupplier) { + public final > Observable buffer(int count, Supplier bufferSupplier) { return buffer(count, count, bufferSupplier); } @@ -5698,7 +5698,7 @@ public final > Observable buffer(int count, C @CheckReturnValue @SchedulerSupport(SchedulerSupport.COMPUTATION) public final Observable> buffer(long timespan, long timeskip, TimeUnit unit) { - return buffer(timespan, timeskip, unit, Schedulers.computation(), ArrayListSupplier.asCallable()); + return buffer(timespan, timeskip, unit, Schedulers.computation(), ArrayListSupplier.asSupplier()); } /** @@ -5731,7 +5731,7 @@ public final Observable> buffer(long timespan, long timeskip, TimeUnit u @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) public final Observable> buffer(long timespan, long timeskip, TimeUnit unit, Scheduler scheduler) { - return buffer(timespan, timeskip, unit, scheduler, ArrayListSupplier.asCallable()); + return buffer(timespan, timeskip, unit, scheduler, ArrayListSupplier.asSupplier()); } /** @@ -5767,7 +5767,7 @@ public final Observable> buffer(long timespan, long timeskip, TimeUnit u */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) - public final > Observable buffer(long timespan, long timeskip, TimeUnit unit, Scheduler scheduler, Callable bufferSupplier) { + public final > Observable buffer(long timespan, long timeskip, TimeUnit unit, Scheduler scheduler, Supplier bufferSupplier) { ObjectHelper.requireNonNull(unit, "unit is null"); ObjectHelper.requireNonNull(scheduler, "scheduler is null"); ObjectHelper.requireNonNull(bufferSupplier, "bufferSupplier is null"); @@ -5868,7 +5868,7 @@ public final Observable> buffer(long timespan, TimeUnit unit, int count) @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) public final Observable> buffer(long timespan, TimeUnit unit, Scheduler scheduler, int count) { - return buffer(timespan, unit, scheduler, count, ArrayListSupplier.asCallable(), false); + return buffer(timespan, unit, scheduler, count, ArrayListSupplier.asSupplier(), false); } /** @@ -5911,7 +5911,7 @@ public final Observable> buffer(long timespan, TimeUnit unit, Scheduler public final > Observable buffer( long timespan, TimeUnit unit, Scheduler scheduler, int count, - Callable bufferSupplier, + Supplier bufferSupplier, boolean restartTimerOnMaxSize) { ObjectHelper.requireNonNull(unit, "unit is null"); ObjectHelper.requireNonNull(scheduler, "scheduler is null"); @@ -5948,7 +5948,7 @@ public final > Observable buffer( @CheckReturnValue @SchedulerSupport(SchedulerSupport.CUSTOM) public final Observable> buffer(long timespan, TimeUnit unit, Scheduler scheduler) { - return buffer(timespan, unit, scheduler, Integer.MAX_VALUE, ArrayListSupplier.asCallable(), false); + return buffer(timespan, unit, scheduler, Integer.MAX_VALUE, ArrayListSupplier.asSupplier(), false); } /** @@ -5980,7 +5980,7 @@ public final Observable> buffer(long timespan, TimeUnit unit, Scheduler public final Observable> buffer( ObservableSource openingIndicator, Function> closingIndicator) { - return buffer(openingIndicator, closingIndicator, ArrayListSupplier.asCallable()); + return buffer(openingIndicator, closingIndicator, ArrayListSupplier.asSupplier()); } /** @@ -6016,7 +6016,7 @@ public final Observable> buffer( public final > Observable buffer( ObservableSource openingIndicator, Function> closingIndicator, - Callable bufferSupplier) { + Supplier bufferSupplier) { ObjectHelper.requireNonNull(openingIndicator, "openingIndicator is null"); ObjectHelper.requireNonNull(closingIndicator, "closingIndicator is null"); ObjectHelper.requireNonNull(bufferSupplier, "bufferSupplier is null"); @@ -6050,7 +6050,7 @@ public final > Observable @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) public final Observable> buffer(ObservableSource boundary) { - return buffer(boundary, ArrayListSupplier.asCallable()); + return buffer(boundary, ArrayListSupplier.asSupplier()); } /** @@ -6116,7 +6116,7 @@ public final Observable> buffer(ObservableSource boundary, final */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final > Observable buffer(ObservableSource boundary, Callable bufferSupplier) { + public final > Observable buffer(ObservableSource boundary, Supplier bufferSupplier) { ObjectHelper.requireNonNull(boundary, "boundary is null"); ObjectHelper.requireNonNull(bufferSupplier, "bufferSupplier is null"); return RxJavaPlugins.onAssembly(new ObservableBufferExactBoundary(this, boundary, bufferSupplier)); @@ -6138,7 +6138,7 @@ public final > Observable buffer(Observabl * * @param the value type of the boundary-providing ObservableSource * @param boundarySupplier - * a {@link Callable} that produces an ObservableSource that governs the boundary between buffers. + * a {@link Supplier} that produces an ObservableSource that governs the boundary between buffers. * Whenever the supplied {@code ObservableSource} emits an item, {@code buffer} emits the current buffer and * begins to fill a new one * @return an Observable that emits a connected, non-overlapping buffer of items from the source ObservableSource @@ -6147,8 +6147,8 @@ public final > Observable buffer(Observabl */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable> buffer(Callable> boundarySupplier) { - return buffer(boundarySupplier, ArrayListSupplier.asCallable()); + public final Observable> buffer(Supplier> boundarySupplier) { + return buffer(boundarySupplier, ArrayListSupplier.asSupplier()); } /** @@ -6168,7 +6168,7 @@ public final Observable> buffer(Callable the collection subclass type to buffer into * @param the value type of the boundary-providing ObservableSource * @param boundarySupplier - * a {@link Callable} that produces an ObservableSource that governs the boundary between buffers. + * a {@link Supplier} that produces an ObservableSource that governs the boundary between buffers. * Whenever the supplied {@code ObservableSource} emits an item, {@code buffer} emits the current buffer and * begins to fill a new one * @param bufferSupplier @@ -6180,7 +6180,7 @@ public final Observable> buffer(Callable> Observable buffer(Callable> boundarySupplier, Callable bufferSupplier) { + public final > Observable buffer(Supplier> boundarySupplier, Supplier bufferSupplier) { ObjectHelper.requireNonNull(boundarySupplier, "boundarySupplier is null"); ObjectHelper.requireNonNull(bufferSupplier, "bufferSupplier is null"); return RxJavaPlugins.onAssembly(new ObservableBufferBoundarySupplier(this, boundarySupplier, bufferSupplier)); @@ -6352,7 +6352,7 @@ public final Observable cast(final Class clazz) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Single collect(Callable initialValueSupplier, BiConsumer collector) { + public final Single collect(Supplier initialValueSupplier, BiConsumer collector) { ObjectHelper.requireNonNull(initialValueSupplier, "initialValueSupplier is null"); ObjectHelper.requireNonNull(collector, "collector is null"); return RxJavaPlugins.onAssembly(new ObservableCollectSingle(this, initialValueSupplier, collector)); @@ -6388,7 +6388,7 @@ public final Single collect(Callable initialValueSupplier, B @SchedulerSupport(SchedulerSupport.NONE) public final Single collectInto(final U initialValue, BiConsumer collector) { ObjectHelper.requireNonNull(initialValue, "initialValue is null"); - return collect(Functions.justCallable(initialValue), collector); + return collect(Functions.justSupplier(initialValue), collector); } /** @@ -6468,9 +6468,9 @@ public final Observable concatMap(Function Observable concatMap(Function> mapper, int prefetch) { ObjectHelper.requireNonNull(mapper, "mapper is null"); ObjectHelper.verifyPositive(prefetch, "prefetch"); - if (this instanceof ScalarCallable) { + if (this instanceof ScalarSupplier) { @SuppressWarnings("unchecked") - T v = ((ScalarCallable)this).call(); + T v = ((ScalarSupplier)this).get(); if (v == null) { return empty(); } @@ -6528,9 +6528,9 @@ public final Observable concatMapDelayError(Function)this).call(); + T v = ((ScalarSupplier)this).get(); if (v == null) { return empty(); } @@ -7789,7 +7789,7 @@ public final Observable dematerialize(Function * to {@code OutOfMemoryError}. *

* Customizing the retention policy can happen only by providing a custom {@link java.util.Collection} implementation - * to the {@link #distinct(Function, Callable)} overload. + * to the {@link #distinct(Function, Supplier)} overload. *

*
Scheduler:
*
{@code distinct} does not operate by default on a particular {@link Scheduler}.
@@ -7799,7 +7799,7 @@ public final Observable dematerialize(Function * each other * @see ReactiveX operators documentation: Distinct * @see #distinct(Function) - * @see #distinct(Function, Callable) + * @see #distinct(Function, Supplier) */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) @@ -7827,7 +7827,7 @@ public final Observable distinct() { * to {@code OutOfMemoryError}. *

* Customizing the retention policy can happen only by providing a custom {@link java.util.Collection} implementation - * to the {@link #distinct(Function, Callable)} overload. + * to the {@link #distinct(Function, Supplier)} overload. *

*
Scheduler:
*
{@code distinct} does not operate by default on a particular {@link Scheduler}.
@@ -7839,7 +7839,7 @@ public final Observable distinct() { * is distinct from another one or not * @return an Observable that emits those items emitted by the source ObservableSource that have distinct keys * @see ReactiveX operators documentation: Distinct - * @see #distinct(Function, Callable) + * @see #distinct(Function, Supplier) */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) @@ -7874,7 +7874,7 @@ public final Observable distinct(Function keySelector) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public final Observable distinct(Function keySelector, Callable> collectionSupplier) { + public final Observable distinct(Function keySelector, Supplier> collectionSupplier) { ObjectHelper.requireNonNull(keySelector, "keySelector is null"); ObjectHelper.requireNonNull(collectionSupplier, "collectionSupplier is null"); return RxJavaPlugins.onAssembly(new ObservableDistinct(this, keySelector, collectionSupplier)); @@ -8605,9 +8605,9 @@ public final Observable flatMap(Function)this).call(); + T v = ((ScalarSupplier)this).get(); if (v == null) { return empty(); } @@ -8645,7 +8645,7 @@ public final Observable flatMap(Function Observable flatMap( Function> onNextMapper, Function> onErrorMapper, - Callable> onCompleteSupplier) { + Supplier> onCompleteSupplier) { ObjectHelper.requireNonNull(onNextMapper, "onNextMapper is null"); ObjectHelper.requireNonNull(onErrorMapper, "onErrorMapper is null"); ObjectHelper.requireNonNull(onCompleteSupplier, "onCompleteSupplier is null"); @@ -8685,7 +8685,7 @@ public final Observable flatMap( public final Observable flatMap( Function> onNextMapper, Function> onErrorMapper, - Callable> onCompleteSupplier, + Supplier> onCompleteSupplier, int maxConcurrency) { ObjectHelper.requireNonNull(onNextMapper, "onNextMapper is null"); ObjectHelper.requireNonNull(onErrorMapper, "onErrorMapper is null"); @@ -10306,7 +10306,7 @@ public final Maybe reduce(BiFunction reducer) { *

* Note that the {@code seed} is shared among all subscribers to the resulting ObservableSource * and may cause problems if it is mutable. To make sure each subscriber gets its own value, defer - * the application of this operator via {@link #defer(Callable)}: + * the application of this operator via {@link #defer(Supplier)}: *


      * ObservableSource<T> source = ...
      * Single.defer(() -> source.reduce(new ArrayList<>(), (list, item) -> list.add(item)));
@@ -10340,7 +10340,7 @@ public final Maybe reduce(BiFunction reducer) {
      *         items emitted by the source ObservableSource
      * @see ReactiveX operators documentation: Reduce
      * @see Wikipedia: Fold (higher-order function)
-     * @see #reduceWith(Callable, BiFunction)
+     * @see #reduceWith(Supplier, BiFunction)
      */
     @CheckReturnValue
     @SchedulerSupport(SchedulerSupport.NONE)
@@ -10373,7 +10373,7 @@ public final  Single reduce(R seed, BiFunction reducer) {
      *
      * @param  the accumulator and output value type
      * @param seedSupplier
-     *            the Callable that provides the initial (seed) accumulator value for each individual Observer
+     *            the Supplier that provides the initial (seed) accumulator value for each individual Observer
      * @param reducer
      *            an accumulator function to be invoked on each item emitted by the source ObservableSource, the
      *            result of which will be used in the next accumulator call
@@ -10384,7 +10384,7 @@ public final  Single reduce(R seed, BiFunction reducer) {
      */
     @CheckReturnValue
     @SchedulerSupport(SchedulerSupport.NONE)
-    public final  Single reduceWith(Callable seedSupplier, BiFunction reducer) {
+    public final  Single reduceWith(Supplier seedSupplier, BiFunction reducer) {
         ObjectHelper.requireNonNull(seedSupplier, "seedSupplier is null");
         ObjectHelper.requireNonNull(reducer, "reducer is null");
         return RxJavaPlugins.onAssembly(new ObservableReduceWithSingle(this, seedSupplier, reducer));
@@ -10536,7 +10536,7 @@ public final ConnectableObservable replay() {
     @SchedulerSupport(SchedulerSupport.NONE)
     public final  Observable replay(Function, ? extends ObservableSource> selector) {
         ObjectHelper.requireNonNull(selector, "selector is null");
-        return ObservableReplay.multicastSelector(ObservableInternalHelper.replayCallable(this), selector);
+        return ObservableReplay.multicastSelector(ObservableInternalHelper.replaySupplier(this), selector);
     }
 
     /**
@@ -10570,7 +10570,7 @@ public final  Observable replay(Function, ? extends
     public final  Observable replay(Function, ? extends ObservableSource> selector, final int bufferSize) {
         ObjectHelper.requireNonNull(selector, "selector is null");
         ObjectHelper.verifyPositive(bufferSize, "bufferSize");
-        return ObservableReplay.multicastSelector(ObservableInternalHelper.replayCallable(this, bufferSize), selector);
+        return ObservableReplay.multicastSelector(ObservableInternalHelper.replaySupplier(this, bufferSize), selector);
     }
 
     /**
@@ -10653,7 +10653,7 @@ public final  Observable replay(Function, ? extends
         ObjectHelper.requireNonNull(unit, "unit is null");
         ObjectHelper.requireNonNull(scheduler, "scheduler is null");
         return ObservableReplay.multicastSelector(
-                ObservableInternalHelper.replayCallable(this, bufferSize, time, unit, scheduler), selector);
+                ObservableInternalHelper.replaySupplier(this, bufferSize, time, unit, scheduler), selector);
     }
 
     /**
@@ -10690,7 +10690,7 @@ public final  Observable replay(final Function, ? ex
         ObjectHelper.requireNonNull(selector, "selector is null");
         ObjectHelper.requireNonNull(scheduler, "scheduler is null");
         ObjectHelper.verifyPositive(bufferSize, "bufferSize");
-        return ObservableReplay.multicastSelector(ObservableInternalHelper.replayCallable(this, bufferSize),
+        return ObservableReplay.multicastSelector(ObservableInternalHelper.replaySupplier(this, bufferSize),
                 ObservableInternalHelper.replayFunction(selector, scheduler));
     }
 
@@ -10758,7 +10758,7 @@ public final  Observable replay(Function, ? extends
         ObjectHelper.requireNonNull(selector, "selector is null");
         ObjectHelper.requireNonNull(unit, "unit is null");
         ObjectHelper.requireNonNull(scheduler, "scheduler is null");
-        return ObservableReplay.multicastSelector(ObservableInternalHelper.replayCallable(this, time, unit, scheduler), selector);
+        return ObservableReplay.multicastSelector(ObservableInternalHelper.replaySupplier(this, time, unit, scheduler), selector);
     }
 
     /**
@@ -10788,7 +10788,7 @@ public final  Observable replay(Function, ? extends
     public final  Observable replay(final Function, ? extends ObservableSource> selector, final Scheduler scheduler) {
         ObjectHelper.requireNonNull(selector, "selector is null");
         ObjectHelper.requireNonNull(scheduler, "scheduler is null");
-        return ObservableReplay.multicastSelector(ObservableInternalHelper.replayCallable(this),
+        return ObservableReplay.multicastSelector(ObservableInternalHelper.replaySupplier(this),
                 ObservableInternalHelper.replayFunction(selector, scheduler));
     }
 
@@ -11468,7 +11468,7 @@ public final Observable scan(BiFunction accumulator) {
      * 

* Note that the {@code initialValue} is shared among all subscribers to the resulting ObservableSource * and may cause problems if it is mutable. To make sure each subscriber gets its own value, defer - * the application of this operator via {@link #defer(Callable)}: + * the application of this operator via {@link #defer(Supplier)}: *


      * ObservableSource<T> source = ...
      * Observable.defer(() -> source.scan(new ArrayList<>(), (list, item) -> list.add(item)));
@@ -11499,7 +11499,7 @@ public final Observable scan(BiFunction accumulator) {
     @SchedulerSupport(SchedulerSupport.NONE)
     public final  Observable scan(final R initialValue, BiFunction accumulator) {
         ObjectHelper.requireNonNull(initialValue, "initialValue is null");
-        return scanWith(Functions.justCallable(initialValue), accumulator);
+        return scanWith(Functions.justSupplier(initialValue), accumulator);
     }
 
     /**
@@ -11521,7 +11521,7 @@ public final  Observable scan(final R initialValue, BiFunction the initial, accumulator and result type
      * @param seedSupplier
-     *            a Callable that returns the initial (seed) accumulator item for each individual Observer
+     *            a Supplier that returns the initial (seed) accumulator item for each individual Observer
      * @param accumulator
      *            an accumulator function to be invoked on each item emitted by the source ObservableSource, whose
      *            result will be emitted to {@link Observer}s via {@link Observer#onNext onNext} and used in the
@@ -11532,7 +11532,7 @@ public final  Observable scan(final R initialValue, BiFunction Observable scanWith(Callable seedSupplier, BiFunction accumulator) {
+    public final  Observable scanWith(Supplier seedSupplier, BiFunction accumulator) {
         ObjectHelper.requireNonNull(seedSupplier, "seedSupplier is null");
         ObjectHelper.requireNonNull(accumulator, "accumulator is null");
         return RxJavaPlugins.onAssembly(new ObservableScanSeed(this, seedSupplier, accumulator));
@@ -12422,9 +12422,9 @@ public final  Observable switchMap(Function Observable switchMap(Function> mapper, int bufferSize) {
         ObjectHelper.requireNonNull(mapper, "mapper is null");
         ObjectHelper.verifyPositive(bufferSize, "bufferSize");
-        if (this instanceof ScalarCallable) {
+        if (this instanceof ScalarSupplier) {
             @SuppressWarnings("unchecked")
-            T v = ((ScalarCallable)this).call();
+            T v = ((ScalarSupplier)this).get();
             if (v == null) {
                 return empty();
             }
@@ -12698,9 +12698,9 @@ public final  Observable switchMapDelayError(Function Observable switchMapDelayError(Function> mapper, int bufferSize) {
         ObjectHelper.requireNonNull(mapper, "mapper is null");
         ObjectHelper.verifyPositive(bufferSize, "bufferSize");
-        if (this instanceof ScalarCallable) {
+        if (this instanceof ScalarSupplier) {
             @SuppressWarnings("unchecked")
-            T v = ((ScalarCallable)this).call();
+            T v = ((ScalarSupplier)this).get();
             if (v == null) {
                 return empty();
             }
@@ -14013,14 +14013,14 @@ public final Single> toList(final int capacityHint) {
      *
      * @param  the subclass of a collection of Ts
      * @param collectionSupplier
-     *               the Callable returning the collection (for each individual Observer) to be filled in
+     *               the Supplier returning the collection (for each individual Observer) to be filled in
      * @return a Single that emits a single item: a List containing all of the items emitted by the source
      *         ObservableSource
      * @see ReactiveX operators documentation: To
      */
     @CheckReturnValue
     @SchedulerSupport(SchedulerSupport.NONE)
-    public final > Single toList(Callable collectionSupplier) {
+    public final > Single toList(Supplier collectionSupplier) {
         ObjectHelper.requireNonNull(collectionSupplier, "collectionSupplier is null");
         return RxJavaPlugins.onAssembly(new ObservableToListSingle(this, collectionSupplier));
     }
@@ -14053,7 +14053,7 @@ public final > Single toList(Callable coll
     @SchedulerSupport(SchedulerSupport.NONE)
     public final  Single> toMap(final Function keySelector) {
         ObjectHelper.requireNonNull(keySelector, "keySelector is null");
-        return collect(HashMapSupplier.asCallable(), Functions.toMapKeySelector(keySelector));
+        return collect(HashMapSupplier.asSupplier(), Functions.toMapKeySelector(keySelector));
     }
 
     /**
@@ -14090,7 +14090,7 @@ public final  Single> toMap(
             final Function valueSelector) {
         ObjectHelper.requireNonNull(keySelector, "keySelector is null");
         ObjectHelper.requireNonNull(valueSelector, "valueSelector is null");
-        return collect(HashMapSupplier.asCallable(), Functions.toMapKeyValueSelector(keySelector, valueSelector));
+        return collect(HashMapSupplier.asSupplier(), Functions.toMapKeyValueSelector(keySelector, valueSelector));
     }
 
     /**
@@ -14124,7 +14124,7 @@ public final  Single> toMap(
     public final  Single> toMap(
             final Function keySelector,
             final Function valueSelector,
-            Callable> mapSupplier) {
+            Supplier> mapSupplier) {
         ObjectHelper.requireNonNull(keySelector, "keySelector is null");
         ObjectHelper.requireNonNull(valueSelector, "valueSelector is null");
         ObjectHelper.requireNonNull(mapSupplier, "mapSupplier is null");
@@ -14157,7 +14157,7 @@ public final  Single> toMap(
     public final  Single>> toMultimap(Function keySelector) {
         @SuppressWarnings({ "rawtypes", "unchecked" })
         Function valueSelector = (Function)Functions.identity();
-        Callable>> mapSupplier = HashMapSupplier.asCallable();
+        Supplier>> mapSupplier = HashMapSupplier.asSupplier();
         Function> collectionFactory = ArrayListSupplier.asFunction();
         return toMultimap(keySelector, valueSelector, mapSupplier, collectionFactory);
     }
@@ -14190,7 +14190,7 @@ public final  Single>> toMultimap(Function Single>> toMultimap(Function keySelector, Function valueSelector) {
-        Callable>> mapSupplier = HashMapSupplier.asCallable();
+        Supplier>> mapSupplier = HashMapSupplier.asSupplier();
         Function> collectionFactory = ArrayListSupplier.asFunction();
         return toMultimap(keySelector, valueSelector, mapSupplier, collectionFactory);
     }
@@ -14225,7 +14225,7 @@ public final  Single>> toMultimap(Function Single>> toMultimap(
             final Function keySelector,
             final Function valueSelector,
-            final Callable>> mapSupplier,
+            final Supplier>> mapSupplier,
             final Function> collectionFactory) {
         ObjectHelper.requireNonNull(keySelector, "keySelector is null");
         ObjectHelper.requireNonNull(valueSelector, "valueSelector is null");
@@ -14266,7 +14266,7 @@ public final  Single>> toMultimap(
     public final  Single>> toMultimap(
             Function keySelector,
             Function valueSelector,
-            Callable>> mapSupplier
+            Supplier>> mapSupplier
             ) {
         return toMultimap(keySelector, valueSelector, mapSupplier, ArrayListSupplier.asFunction());
     }
@@ -15022,7 +15022,7 @@ public final  Observable> window(
      *
      * @param  the element type of the boundary ObservableSource
      * @param boundary
-     *            a {@link Callable} that returns an {@code ObservableSource} that governs the boundary between windows.
+     *            a {@link Supplier} that returns an {@code ObservableSource} that governs the boundary between windows.
      *            When the source {@code ObservableSource} emits an item, {@code window} emits the current window and begins
      *            a new one.
      * @return an Observable that emits connected, non-overlapping windows of items from the source ObservableSource
@@ -15031,7 +15031,7 @@ public final  Observable> window(
      */
     @CheckReturnValue
     @SchedulerSupport(SchedulerSupport.NONE)
-    public final  Observable> window(Callable> boundary) {
+    public final  Observable> window(Supplier> boundary) {
         return window(boundary, bufferSize());
     }
 
@@ -15048,7 +15048,7 @@ public final  Observable> window(Callable the element type of the boundary ObservableSource
      * @param boundary
-     *            a {@link Callable} that returns an {@code ObservableSource} that governs the boundary between windows.
+     *            a {@link Supplier} that returns an {@code ObservableSource} that governs the boundary between windows.
      *            When the source {@code ObservableSource} emits an item, {@code window} emits the current window and begins
      *            a new one.
      * @param bufferSize
@@ -15059,7 +15059,7 @@ public final  Observable> window(Callable Observable> window(Callable> boundary, int bufferSize) {
+    public final  Observable> window(Supplier> boundary, int bufferSize) {
         ObjectHelper.requireNonNull(boundary, "boundary is null");
         ObjectHelper.verifyPositive(bufferSize, "bufferSize");
         return RxJavaPlugins.onAssembly(new ObservableWindowBoundarySupplier(this, boundary, bufferSize));
diff --git a/src/main/java/io/reactivex/Single.java b/src/main/java/io/reactivex/Single.java
index f97f4d22b7..f0e2f32bb8 100644
--- a/src/main/java/io/reactivex/Single.java
+++ b/src/main/java/io/reactivex/Single.java
@@ -520,7 +520,7 @@ public static  Single create(SingleOnSubscribe source) {
     }
 
     /**
-     * Calls a {@link Callable} for each individual {@link SingleObserver} to return the actual {@link SingleSource} to
+     * Calls a {@link Supplier} for each individual {@link SingleObserver} to return the actual {@link SingleSource} to
      * be subscribed to.
      * 

* @@ -529,14 +529,14 @@ public static Single create(SingleOnSubscribe source) { *

{@code defer} does not operate by default on a particular {@link Scheduler}.
*
* @param the value type - * @param singleSupplier the {@code Callable} that is called for each individual {@code SingleObserver} and + * @param singleSupplier the {@code Supplier} that is called for each individual {@code SingleObserver} and * returns a SingleSource instance to subscribe to * @return the new Single instance */ @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Single defer(final Callable> singleSupplier) { + public static Single defer(final Supplier> singleSupplier) { ObjectHelper.requireNonNull(singleSupplier, "singleSupplier is null"); return RxJavaPlugins.onAssembly(new SingleDefer(singleSupplier)); } @@ -550,14 +550,14 @@ public static Single defer(final Callable{@code error} does not operate by default on a particular {@link Scheduler}. *
* @param the value type - * @param errorSupplier the callable that is called for each individual SingleObserver and + * @param errorSupplier the Supplier that is called for each individual SingleObserver and * returns a Throwable instance to be emitted. * @return the new Single instance */ @CheckReturnValue @NonNull @SchedulerSupport(SchedulerSupport.NONE) - public static Single error(final Callable errorSupplier) { + public static Single error(final Supplier errorSupplier) { ObjectHelper.requireNonNull(errorSupplier, "errorSupplier is null"); return RxJavaPlugins.onAssembly(new SingleError(errorSupplier)); } @@ -585,7 +585,7 @@ public static Single error(final Callable errorSuppl @SchedulerSupport(SchedulerSupport.NONE) public static Single error(final Throwable exception) { ObjectHelper.requireNonNull(exception, "exception is null"); - return error(Functions.justCallable(exception)); + return error(Functions.justSupplier(exception)); } /** @@ -1402,7 +1402,7 @@ public static Single unsafeCreate(SingleSource onSubscribe) { * * @param the value type of the SingleSource generated * @param the resource type - * @param resourceSupplier the Callable called for each SingleObserver to generate a resource Object + * @param resourceSupplier the Supplier called for each SingleObserver to generate a resource Object * @param singleFunction the function called with the returned resource * Object from {@code resourceSupplier} and should return a SingleSource instance * to be run by the operator @@ -1414,7 +1414,7 @@ public static Single unsafeCreate(SingleSource onSubscribe) { */ @CheckReturnValue @SchedulerSupport(SchedulerSupport.NONE) - public static Single using(Callable resourceSupplier, + public static Single using(Supplier resourceSupplier, Function> singleFunction, Consumer disposer) { return using(resourceSupplier, singleFunction, disposer, true); @@ -1429,7 +1429,7 @@ public static Single using(Callable resourceSupplier, * * @param the value type of the SingleSource generated * @param the resource type - * @param resourceSupplier the Callable called for each SingleObserver to generate a resource Object + * @param resourceSupplier the Supplier called for each SingleObserver to generate a resource Object * @param singleFunction the function called with the returned resource * Object from {@code resourceSupplier} and should return a SingleSource instance * to be run by the operator @@ -1446,7 +1446,7 @@ public static Single using(Callable resourceSupplier, @NonNull @SchedulerSupport(SchedulerSupport.NONE) public static Single using( - final Callable resourceSupplier, + final Supplier resourceSupplier, final Function> singleFunction, final Consumer disposer, final boolean eager) { diff --git a/src/main/java/io/reactivex/functions/Action.java b/src/main/java/io/reactivex/functions/Action.java index 826b84535f..a871855925 100644 --- a/src/main/java/io/reactivex/functions/Action.java +++ b/src/main/java/io/reactivex/functions/Action.java @@ -19,7 +19,7 @@ public interface Action { /** * Runs the action and optionally throws a checked exception. - * @throws Exception if the implementation wishes to throw a checked exception + * @throws Throwable if the implementation wishes to throw any type of exception */ - void run() throws Exception; + void run() throws Throwable; } diff --git a/src/main/java/io/reactivex/functions/BiConsumer.java b/src/main/java/io/reactivex/functions/BiConsumer.java index 6b147ae0b0..66cd9ea744 100644 --- a/src/main/java/io/reactivex/functions/BiConsumer.java +++ b/src/main/java/io/reactivex/functions/BiConsumer.java @@ -24,7 +24,7 @@ public interface BiConsumer { * Performs an operation on the given values. * @param t1 the first value * @param t2 the second value - * @throws Exception on error + * @throws Throwable if the implementation wishes to throw any type of exception */ - void accept(T1 t1, T2 t2) throws Exception; + void accept(T1 t1, T2 t2) throws Throwable; } diff --git a/src/main/java/io/reactivex/functions/BiFunction.java b/src/main/java/io/reactivex/functions/BiFunction.java index f67a03bdb8..e85638ebd6 100644 --- a/src/main/java/io/reactivex/functions/BiFunction.java +++ b/src/main/java/io/reactivex/functions/BiFunction.java @@ -28,8 +28,8 @@ public interface BiFunction { * @param t1 the first value * @param t2 the second value * @return the result value - * @throws Exception on error + * @throws Throwable if the implementation wishes to throw any type of exception */ @NonNull - R apply(@NonNull T1 t1, @NonNull T2 t2) throws Exception; + R apply(@NonNull T1 t1, @NonNull T2 t2) throws Throwable; } diff --git a/src/main/java/io/reactivex/functions/BiPredicate.java b/src/main/java/io/reactivex/functions/BiPredicate.java index 390e1640ec..f0bbe532e5 100644 --- a/src/main/java/io/reactivex/functions/BiPredicate.java +++ b/src/main/java/io/reactivex/functions/BiPredicate.java @@ -27,7 +27,7 @@ public interface BiPredicate { * @param t1 the first value * @param t2 the second value * @return the boolean result - * @throws Exception on error + * @throws Throwable if the implementation wishes to throw any type of exception */ - boolean test(@NonNull T1 t1, @NonNull T2 t2) throws Exception; + boolean test(@NonNull T1 t1, @NonNull T2 t2) throws Throwable; } diff --git a/src/main/java/io/reactivex/functions/BooleanSupplier.java b/src/main/java/io/reactivex/functions/BooleanSupplier.java index be928f9abb..7e91eab38b 100644 --- a/src/main/java/io/reactivex/functions/BooleanSupplier.java +++ b/src/main/java/io/reactivex/functions/BooleanSupplier.java @@ -20,7 +20,7 @@ public interface BooleanSupplier { /** * Returns a boolean value. * @return a boolean value - * @throws Exception on error + * @throws Throwable if the implementation wishes to throw any type of exception */ - boolean getAsBoolean() throws Exception; // NOPMD + boolean getAsBoolean() throws Throwable; // NOPMD } diff --git a/src/main/java/io/reactivex/functions/Cancellable.java b/src/main/java/io/reactivex/functions/Cancellable.java index b4d5ae56e9..e28c6fe53d 100644 --- a/src/main/java/io/reactivex/functions/Cancellable.java +++ b/src/main/java/io/reactivex/functions/Cancellable.java @@ -21,7 +21,7 @@ public interface Cancellable { /** * Cancel the action or free a resource. - * @throws Exception on error + * @throws Throwable if the implementation wishes to throw any type of exception */ - void cancel() throws Exception; + void cancel() throws Throwable; } diff --git a/src/main/java/io/reactivex/functions/Consumer.java b/src/main/java/io/reactivex/functions/Consumer.java index ff10bbb244..afa65e9164 100644 --- a/src/main/java/io/reactivex/functions/Consumer.java +++ b/src/main/java/io/reactivex/functions/Consumer.java @@ -21,7 +21,7 @@ public interface Consumer { /** * Consume the given value. * @param t the value - * @throws Exception on error + * @throws Throwable if the implementation wishes to throw any type of exception */ - void accept(T t) throws Exception; + void accept(T t) throws Throwable; } diff --git a/src/main/java/io/reactivex/functions/Function.java b/src/main/java/io/reactivex/functions/Function.java index 7c6d095314..71eea769bb 100644 --- a/src/main/java/io/reactivex/functions/Function.java +++ b/src/main/java/io/reactivex/functions/Function.java @@ -27,7 +27,7 @@ public interface Function { * Apply some calculation to the input value and return some other value. * @param t the input value * @return the output value - * @throws Exception on error + * @throws Throwable if the implementation wishes to throw any type of exception */ - R apply(@NonNull T t) throws Exception; + R apply(@NonNull T t) throws Throwable; } diff --git a/src/main/java/io/reactivex/functions/Function3.java b/src/main/java/io/reactivex/functions/Function3.java index f3b49d8a69..87bc13ee70 100644 --- a/src/main/java/io/reactivex/functions/Function3.java +++ b/src/main/java/io/reactivex/functions/Function3.java @@ -29,8 +29,8 @@ public interface Function3 { * @param t2 the second value * @param t3 the third value * @return the result value - * @throws Exception on error + * @throws Throwable if the implementation wishes to throw any type of exception */ @NonNull - R apply(@NonNull T1 t1, @NonNull T2 t2, @NonNull T3 t3) throws Exception; + R apply(@NonNull T1 t1, @NonNull T2 t2, @NonNull T3 t3) throws Throwable; } diff --git a/src/main/java/io/reactivex/functions/Function4.java b/src/main/java/io/reactivex/functions/Function4.java index 70e921d2dd..5df1bcf98e 100644 --- a/src/main/java/io/reactivex/functions/Function4.java +++ b/src/main/java/io/reactivex/functions/Function4.java @@ -31,8 +31,8 @@ public interface Function4 { * @param t3 the third value * @param t4 the fourth value * @return the result value - * @throws Exception on error + * @throws Throwable if the implementation wishes to throw any type of exception */ @NonNull - R apply(@NonNull T1 t1, @NonNull T2 t2, @NonNull T3 t3, @NonNull T4 t4) throws Exception; + R apply(@NonNull T1 t1, @NonNull T2 t2, @NonNull T3 t3, @NonNull T4 t4) throws Throwable; } diff --git a/src/main/java/io/reactivex/functions/Function5.java b/src/main/java/io/reactivex/functions/Function5.java index 32ccfe16d3..1bb52951d5 100644 --- a/src/main/java/io/reactivex/functions/Function5.java +++ b/src/main/java/io/reactivex/functions/Function5.java @@ -33,8 +33,8 @@ public interface Function5 { * @param t4 the fourth value * @param t5 the fifth value * @return the result value - * @throws Exception on error + * @throws Throwable if the implementation wishes to throw any type of exception */ @NonNull - R apply(@NonNull T1 t1, @NonNull T2 t2, @NonNull T3 t3, @NonNull T4 t4, @NonNull T5 t5) throws Exception; + R apply(@NonNull T1 t1, @NonNull T2 t2, @NonNull T3 t3, @NonNull T4 t4, @NonNull T5 t5) throws Throwable; } diff --git a/src/main/java/io/reactivex/functions/Function6.java b/src/main/java/io/reactivex/functions/Function6.java index c011545c98..2096504cda 100644 --- a/src/main/java/io/reactivex/functions/Function6.java +++ b/src/main/java/io/reactivex/functions/Function6.java @@ -35,8 +35,8 @@ public interface Function6 { * @param t5 the fifth value * @param t6 the sixth value * @return the result value - * @throws Exception on error + * @throws Throwable if the implementation wishes to throw any type of exception */ @NonNull - R apply(@NonNull T1 t1, @NonNull T2 t2, @NonNull T3 t3, @NonNull T4 t4, @NonNull T5 t5, @NonNull T6 t6) throws Exception; + R apply(@NonNull T1 t1, @NonNull T2 t2, @NonNull T3 t3, @NonNull T4 t4, @NonNull T5 t5, @NonNull T6 t6) throws Throwable; } diff --git a/src/main/java/io/reactivex/functions/Function7.java b/src/main/java/io/reactivex/functions/Function7.java index bb8dee9ed3..a96984350c 100644 --- a/src/main/java/io/reactivex/functions/Function7.java +++ b/src/main/java/io/reactivex/functions/Function7.java @@ -37,8 +37,8 @@ public interface Function7 { * @param t6 the sixth value * @param t7 the seventh value * @return the result value - * @throws Exception on error + * @throws Throwable if the implementation wishes to throw any type of exception */ @NonNull - R apply(@NonNull T1 t1, @NonNull T2 t2, @NonNull T3 t3, @NonNull T4 t4, @NonNull T5 t5, @NonNull T6 t6, @NonNull T7 t7) throws Exception; + R apply(@NonNull T1 t1, @NonNull T2 t2, @NonNull T3 t3, @NonNull T4 t4, @NonNull T5 t5, @NonNull T6 t6, @NonNull T7 t7) throws Throwable; } diff --git a/src/main/java/io/reactivex/functions/Function8.java b/src/main/java/io/reactivex/functions/Function8.java index 8b8785ea91..433b9ba416 100644 --- a/src/main/java/io/reactivex/functions/Function8.java +++ b/src/main/java/io/reactivex/functions/Function8.java @@ -39,8 +39,8 @@ public interface Function8 { * @param t7 the seventh value * @param t8 the eighth value * @return the result value - * @throws Exception on error + * @throws Throwable if the implementation wishes to throw any type of exception */ @NonNull - R apply(@NonNull T1 t1, @NonNull T2 t2, @NonNull T3 t3, @NonNull T4 t4, @NonNull T5 t5, @NonNull T6 t6, @NonNull T7 t7, @NonNull T8 t8) throws Exception; + R apply(@NonNull T1 t1, @NonNull T2 t2, @NonNull T3 t3, @NonNull T4 t4, @NonNull T5 t5, @NonNull T6 t6, @NonNull T7 t7, @NonNull T8 t8) throws Throwable; } diff --git a/src/main/java/io/reactivex/functions/Function9.java b/src/main/java/io/reactivex/functions/Function9.java index 11e7926c5c..7f426a972c 100644 --- a/src/main/java/io/reactivex/functions/Function9.java +++ b/src/main/java/io/reactivex/functions/Function9.java @@ -41,8 +41,8 @@ public interface Function9 { * @param t8 the eighth value * @param t9 the ninth value * @return the result value - * @throws Exception on error + * @throws Throwable if the implementation wishes to throw any type of exception */ @NonNull - R apply(@NonNull T1 t1, @NonNull T2 t2, @NonNull T3 t3, @NonNull T4 t4, @NonNull T5 t5, @NonNull T6 t6, @NonNull T7 t7, @NonNull T8 t8, @NonNull T9 t9) throws Exception; + R apply(@NonNull T1 t1, @NonNull T2 t2, @NonNull T3 t3, @NonNull T4 t4, @NonNull T5 t5, @NonNull T6 t6, @NonNull T7 t7, @NonNull T8 t8, @NonNull T9 t9) throws Throwable; } diff --git a/src/main/java/io/reactivex/functions/IntFunction.java b/src/main/java/io/reactivex/functions/IntFunction.java index aef60e1bd7..167328c2ce 100644 --- a/src/main/java/io/reactivex/functions/IntFunction.java +++ b/src/main/java/io/reactivex/functions/IntFunction.java @@ -23,8 +23,8 @@ public interface IntFunction { * Calculates a value based on a primitive integer input. * @param i the input value * @return the result Object - * @throws Exception on error + * @throws Throwable if the implementation wishes to throw any type of exception */ @NonNull - T apply(int i) throws Exception; + T apply(int i) throws Throwable; } diff --git a/src/main/java/io/reactivex/functions/LongConsumer.java b/src/main/java/io/reactivex/functions/LongConsumer.java index c233f85441..a921ae18df 100644 --- a/src/main/java/io/reactivex/functions/LongConsumer.java +++ b/src/main/java/io/reactivex/functions/LongConsumer.java @@ -19,7 +19,7 @@ public interface LongConsumer { /** * Consume a primitive long input. * @param t the primitive long value - * @throws Exception on error + * @throws Throwable if the implementation wishes to throw any type of exception */ - void accept(long t) throws Exception; + void accept(long t) throws Throwable; } diff --git a/src/main/java/io/reactivex/functions/Predicate.java b/src/main/java/io/reactivex/functions/Predicate.java index 17bc3cff63..7534454e37 100644 --- a/src/main/java/io/reactivex/functions/Predicate.java +++ b/src/main/java/io/reactivex/functions/Predicate.java @@ -24,7 +24,7 @@ public interface Predicate { * Test the given input value and return a boolean. * @param t the value * @return the boolean result - * @throws Exception on error + * @throws Throwable if the implementation wishes to throw any type of exception */ - boolean test(@NonNull T t) throws Exception; + boolean test(@NonNull T t) throws Throwable; } diff --git a/src/main/java/io/reactivex/functions/Supplier.java b/src/main/java/io/reactivex/functions/Supplier.java new file mode 100644 index 0000000000..8ce42202f3 --- /dev/null +++ b/src/main/java/io/reactivex/functions/Supplier.java @@ -0,0 +1,33 @@ +/** + * Copyright (c) 2016-present, RxJava Contributors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is + * distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See + * the License for the specific language governing permissions and limitations under the License. + */ + +package io.reactivex.functions; + +/** + * A functional interface (callback) that provides a single value or + * throws an exception. + *

+ * Thins interface was added to allow throwing any subclass of {@link Throwable}s, + * which is not directly possible with the Java standard {@link java.util.Callable} interface. + * @param the value type returned + * @since 3.0.0 + */ +public interface Supplier { + + /** + * Produces a value or throws an exception. + * @return the value produced + * @throws Throwable if the implementation wishes to throw any type of exception + */ + T get() throws Throwable; +} diff --git a/src/main/java/io/reactivex/internal/disposables/CancellableDisposable.java b/src/main/java/io/reactivex/internal/disposables/CancellableDisposable.java index 446dd6cdf6..ba5750a34c 100644 --- a/src/main/java/io/reactivex/internal/disposables/CancellableDisposable.java +++ b/src/main/java/io/reactivex/internal/disposables/CancellableDisposable.java @@ -46,7 +46,7 @@ public void dispose() { if (c != null) { try { c.cancel(); - } catch (Exception ex) { + } catch (Throwable ex) { Exceptions.throwIfFatal(ex); RxJavaPlugins.onError(ex); } diff --git a/src/main/java/io/reactivex/internal/functions/Functions.java b/src/main/java/io/reactivex/internal/functions/Functions.java index 6aee33fea3..8247648331 100644 --- a/src/main/java/io/reactivex/internal/functions/Functions.java +++ b/src/main/java/io/reactivex/internal/functions/Functions.java @@ -120,7 +120,7 @@ public static Consumer emptyConsumer() { static final Predicate ALWAYS_FALSE = new FalsePredicate(); - static final Callable NULL_SUPPLIER = new NullCallable(); + static final Supplier NULL_SUPPLIER = new NullProvider(); static final Comparator NATURAL_COMPARATOR = new NaturalObjectComparator(); @@ -135,8 +135,8 @@ public static Predicate alwaysFalse() { } @SuppressWarnings("unchecked") - public static Callable nullSupplier() { - return (Callable)NULL_SUPPLIER; + public static Supplier nullSupplier() { + return (Supplier)NULL_SUPPLIER; } /** @@ -171,7 +171,7 @@ public static Action futureAction(Future future) { return new FutureAction(future); } - static final class JustValue implements Callable, Function { + static final class JustValue implements Callable, Supplier, Function { final U value; JustValue(U value) { @@ -187,6 +187,11 @@ public U call() throws Exception { public U apply(T t) throws Exception { return value; } + + @Override + public U get() throws Throwable { + return value; + } } /** @@ -199,6 +204,16 @@ public static Callable justCallable(T value) { return new JustValue(value); } + /** + * Returns a Supplier that returns the given value. + * @param the value type + * @param value the value to return + * @return the new Callable instance + */ + public static Supplier justSupplier(T value) { + return new JustValue(value); + } + /** * Returns a Function that ignores its parameter and returns the given value. * @param the function's input type @@ -234,7 +249,7 @@ public static Function castFunction(Class target) { return new CastToClass(target); } - static final class ArrayListCapacityCallable implements Callable> { + static final class ArrayListCapacityCallable implements Supplier> { final int capacity; ArrayListCapacityCallable(int capacity) { @@ -242,12 +257,12 @@ static final class ArrayListCapacityCallable implements Callable> { } @Override - public List call() throws Exception { + public List get() throws Exception { return new ArrayList(capacity); } } - public static Callable> createArrayList(int capacity) { + public static Supplier> createArrayList(int capacity) { return new ArrayListCapacityCallable(capacity); } @@ -268,17 +283,22 @@ public static Predicate equalsWith(T value) { return new EqualsPredicate(value); } - enum HashSetCallable implements Callable> { + enum HashSetCallable implements Supplier>, Callable> { INSTANCE; @Override public Set call() throws Exception { return new HashSet(); } + + @Override + public Set get() throws Throwable { + return new HashSet(); + } } @SuppressWarnings({ "rawtypes", "unchecked" }) - public static Callable> createHashSet() { - return (Callable)HashSetCallable.INSTANCE; + public static Supplier> createHashSet() { + return (Supplier)HashSetCallable.INSTANCE; } static final class NotificationOnNext implements Consumer { @@ -289,7 +309,7 @@ static final class NotificationOnNext implements Consumer { } @Override - public void accept(T v) throws Exception { + public void accept(T v) throws Throwable { onNotification.accept(Notification.createOnNext(v)); } } @@ -302,7 +322,7 @@ static final class NotificationOnError implements Consumer { } @Override - public void accept(Throwable v) throws Exception { + public void accept(Throwable v) throws Throwable { onNotification.accept(Notification.createOnError(v)); } } @@ -315,7 +335,7 @@ static final class NotificationOnComplete implements Action { } @Override - public void run() throws Exception { + public void run() throws Throwable { onNotification.accept(Notification.createOnComplete()); } } @@ -340,7 +360,7 @@ static final class ActionConsumer implements Consumer { } @Override - public void accept(T t) throws Exception { + public void accept(T t) throws Throwable { action.run(); } } @@ -374,7 +394,7 @@ static final class BooleanSupplierPredicateReverse implements Predicate { } @Override - public boolean test(T t) throws Exception { + public boolean test(T t) throws Throwable { return !supplier.getAsBoolean(); } } @@ -411,7 +431,7 @@ static final class ToMapKeySelector implements BiConsumer, T> { } @Override - public void accept(Map m, T t) throws Exception { + public void accept(Map m, T t) throws Throwable { K key = keySelector.apply(t); m.put(key, t); } @@ -432,7 +452,7 @@ static final class ToMapKeyValueSelector implements BiConsumer m, T t) throws Exception { + public void accept(Map m, T t) throws Throwable { K key = keySelector.apply(t); V value = valueSelector.apply(t); m.put(key, value); @@ -457,7 +477,7 @@ static final class ToMultimapKeyValueSelector implements BiConsumer> m, T t) throws Exception { + public void accept(Map> m, T t) throws Throwable { K key = keySelector.apply(t); Collection coll = m.get(key); @@ -522,7 +542,7 @@ static final class Array2Func implements Function { @SuppressWarnings("unchecked") @Override - public R apply(Object[] a) throws Exception { + public R apply(Object[] a) throws Throwable { if (a.length != 2) { throw new IllegalArgumentException("Array of size 2 expected but got " + a.length); } @@ -539,7 +559,7 @@ static final class Array3Func implements Function { @SuppressWarnings("unchecked") @Override - public R apply(Object[] a) throws Exception { + public R apply(Object[] a) throws Throwable { if (a.length != 3) { throw new IllegalArgumentException("Array of size 3 expected but got " + a.length); } @@ -556,7 +576,7 @@ static final class Array4Func implements Function implements Function implements Function implements Function @SuppressWarnings("unchecked") @Override - public R apply(Object[] a) throws Exception { + public R apply(Object[] a) throws Throwable { if (a.length != 7) { throw new IllegalArgumentException("Array of size 7 expected but got " + a.length); } @@ -624,7 +644,7 @@ static final class Array8Func implements Func @SuppressWarnings("unchecked") @Override - public R apply(Object[] a) throws Exception { + public R apply(Object[] a) throws Throwable { if (a.length != 8) { throw new IllegalArgumentException("Array of size 8 expected but got " + a.length); } @@ -641,7 +661,7 @@ static final class Array9Func implements @SuppressWarnings("unchecked") @Override - public R apply(Object[] a) throws Exception { + public R apply(Object[] a) throws Throwable { if (a.length != 9) { throw new IllegalArgumentException("Array of size 9 expected but got " + a.length); } @@ -724,11 +744,16 @@ public boolean test(Object o) { } } - static final class NullCallable implements Callable { + static final class NullProvider implements Callable, Supplier { @Override public Object call() { return null; } + + @Override + public Object get() throws Throwable { + return null; + } } static final class NaturalObjectComparator implements Comparator { diff --git a/src/main/java/io/reactivex/internal/fuseable/ScalarCallable.java b/src/main/java/io/reactivex/internal/fuseable/ScalarSupplier.java similarity index 84% rename from src/main/java/io/reactivex/internal/fuseable/ScalarCallable.java rename to src/main/java/io/reactivex/internal/fuseable/ScalarSupplier.java index 13ac1655ec..cc5abbab18 100644 --- a/src/main/java/io/reactivex/internal/fuseable/ScalarCallable.java +++ b/src/main/java/io/reactivex/internal/fuseable/ScalarSupplier.java @@ -12,7 +12,7 @@ */ package io.reactivex.internal.fuseable; -import java.util.concurrent.Callable; +import io.reactivex.functions.Supplier; /** * A marker interface indicating that a scalar, constant value @@ -22,16 +22,16 @@ *

* Implementors of {@link #call()} should not throw any exception. *

- * Design note: the interface extends {@link Callable} because if a scalar + * Design note: the interface extends {@link Supplier} because if a scalar * is safe to extract during assembly time, it is also safe to extract at * subscription time or later. This allows optimizations to deal with such * single-element sources uniformly. *

* @param the scalar value type held by the implementing reactive type */ -public interface ScalarCallable extends Callable { +public interface ScalarSupplier extends Supplier { - // overridden to remove the throws Exception + // overridden to remove the throws Throwable @Override - T call(); + T get(); } diff --git a/src/main/java/io/reactivex/internal/fuseable/SimpleQueue.java b/src/main/java/io/reactivex/internal/fuseable/SimpleQueue.java index db0fe9583a..e5cb104bb6 100644 --- a/src/main/java/io/reactivex/internal/fuseable/SimpleQueue.java +++ b/src/main/java/io/reactivex/internal/fuseable/SimpleQueue.java @@ -48,11 +48,11 @@ public interface SimpleQueue { * item, the second poll() is guaranteed to return a non-null item * as well. * @return the item or null to indicate an empty queue - * @throws Exception if some pre-processing of the dequeued + * @throws Throwable if some pre-processing of the dequeued * item (usually through fused functions) throws. */ @Nullable - T poll() throws Exception; + T poll() throws Throwable; /** * Returns true if the queue is empty. diff --git a/src/main/java/io/reactivex/internal/operators/completable/CompletableDefer.java b/src/main/java/io/reactivex/internal/operators/completable/CompletableDefer.java index 030ca4fd3d..029f1a3278 100644 --- a/src/main/java/io/reactivex/internal/operators/completable/CompletableDefer.java +++ b/src/main/java/io/reactivex/internal/operators/completable/CompletableDefer.java @@ -13,18 +13,17 @@ package io.reactivex.internal.operators.completable; -import java.util.concurrent.Callable; - import io.reactivex.*; import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.Supplier; import io.reactivex.internal.disposables.EmptyDisposable; import io.reactivex.internal.functions.ObjectHelper; public final class CompletableDefer extends Completable { - final Callable completableSupplier; + final Supplier completableSupplier; - public CompletableDefer(Callable completableSupplier) { + public CompletableDefer(Supplier completableSupplier) { this.completableSupplier = completableSupplier; } @@ -33,7 +32,7 @@ protected void subscribeActual(CompletableObserver observer) { CompletableSource c; try { - c = ObjectHelper.requireNonNull(completableSupplier.call(), "The completableSupplier returned a null CompletableSource"); + c = ObjectHelper.requireNonNull(completableSupplier.get(), "The completableSupplier returned a null CompletableSource"); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptyDisposable.error(e, observer); diff --git a/src/main/java/io/reactivex/internal/operators/completable/CompletableErrorSupplier.java b/src/main/java/io/reactivex/internal/operators/completable/CompletableErrorSupplier.java index 16df486c42..5b10600cd3 100644 --- a/src/main/java/io/reactivex/internal/operators/completable/CompletableErrorSupplier.java +++ b/src/main/java/io/reactivex/internal/operators/completable/CompletableErrorSupplier.java @@ -13,18 +13,17 @@ package io.reactivex.internal.operators.completable; -import io.reactivex.internal.functions.ObjectHelper; -import java.util.concurrent.Callable; - import io.reactivex.*; import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.Supplier; import io.reactivex.internal.disposables.EmptyDisposable; +import io.reactivex.internal.functions.ObjectHelper; public final class CompletableErrorSupplier extends Completable { - final Callable errorSupplier; + final Supplier errorSupplier; - public CompletableErrorSupplier(Callable errorSupplier) { + public CompletableErrorSupplier(Supplier errorSupplier) { this.errorSupplier = errorSupplier; } @@ -33,7 +32,7 @@ protected void subscribeActual(CompletableObserver observer) { Throwable error; try { - error = ObjectHelper.requireNonNull(errorSupplier.call(), "The error returned is null"); + error = ObjectHelper.requireNonNull(errorSupplier.get(), "The error returned is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); error = e; diff --git a/src/main/java/io/reactivex/internal/operators/completable/CompletableToSingle.java b/src/main/java/io/reactivex/internal/operators/completable/CompletableToSingle.java index e0e5559723..30d5d6f1a6 100644 --- a/src/main/java/io/reactivex/internal/operators/completable/CompletableToSingle.java +++ b/src/main/java/io/reactivex/internal/operators/completable/CompletableToSingle.java @@ -13,21 +13,20 @@ package io.reactivex.internal.operators.completable; -import java.util.concurrent.Callable; - import io.reactivex.*; import io.reactivex.disposables.Disposable; import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.Supplier; public final class CompletableToSingle extends Single { final CompletableSource source; - final Callable completionValueSupplier; + final Supplier completionValueSupplier; final T completionValue; public CompletableToSingle(CompletableSource source, - Callable completionValueSupplier, T completionValue) { + Supplier completionValueSupplier, T completionValue) { this.source = source; this.completionValue = completionValue; this.completionValueSupplier = completionValueSupplier; @@ -52,7 +51,7 @@ public void onComplete() { if (completionValueSupplier != null) { try { - v = completionValueSupplier.call(); + v = completionValueSupplier.get(); } catch (Throwable e) { Exceptions.throwIfFatal(e); observer.onError(e); diff --git a/src/main/java/io/reactivex/internal/operators/completable/CompletableUsing.java b/src/main/java/io/reactivex/internal/operators/completable/CompletableUsing.java index 1f107f2c00..f6fa30ef7f 100644 --- a/src/main/java/io/reactivex/internal/operators/completable/CompletableUsing.java +++ b/src/main/java/io/reactivex/internal/operators/completable/CompletableUsing.java @@ -13,7 +13,6 @@ package io.reactivex.internal.operators.completable; -import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicReference; import io.reactivex.*; @@ -26,12 +25,12 @@ public final class CompletableUsing extends Completable { - final Callable resourceSupplier; + final Supplier resourceSupplier; final Function completableFunction; final Consumer disposer; final boolean eager; - public CompletableUsing(Callable resourceSupplier, + public CompletableUsing(Supplier resourceSupplier, Function completableFunction, Consumer disposer, boolean eager) { this.resourceSupplier = resourceSupplier; @@ -45,7 +44,7 @@ protected void subscribeActual(CompletableObserver observer) { R resource; try { - resource = resourceSupplier.call(); + resource = resourceSupplier.get(); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); EmptyDisposable.error(ex, observer); diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableBuffer.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableBuffer.java index f2f940ac2e..f77ad2d50e 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableBuffer.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableBuffer.java @@ -14,14 +14,13 @@ package io.reactivex.internal.operators.flowable; import java.util.*; -import java.util.concurrent.Callable; import java.util.concurrent.atomic.*; import org.reactivestreams.*; import io.reactivex.*; import io.reactivex.exceptions.Exceptions; -import io.reactivex.functions.BooleanSupplier; +import io.reactivex.functions.*; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.subscriptions.SubscriptionHelper; import io.reactivex.internal.util.*; @@ -32,9 +31,9 @@ public final class FlowableBuffer> extends Ab final int skip; - final Callable bufferSupplier; + final Supplier bufferSupplier; - public FlowableBuffer(Flowable source, int size, int skip, Callable bufferSupplier) { + public FlowableBuffer(Flowable source, int size, int skip, Supplier bufferSupplier) { super(source); this.size = size; this.skip = skip; @@ -57,7 +56,7 @@ static final class PublisherBufferExactSubscriber downstream; - final Callable bufferSupplier; + final Supplier bufferSupplier; final int size; @@ -69,7 +68,7 @@ static final class PublisherBufferExactSubscriber actual, int size, Callable bufferSupplier) { + PublisherBufferExactSubscriber(Subscriber actual, int size, Supplier bufferSupplier) { this.downstream = actual; this.size = size; this.bufferSupplier = bufferSupplier; @@ -106,7 +105,7 @@ public void onNext(T t) { if (b == null) { try { - b = ObjectHelper.requireNonNull(bufferSupplier.call(), "The bufferSupplier returned a null buffer"); + b = ObjectHelper.requireNonNull(bufferSupplier.get(), "The bufferSupplier returned a null buffer"); } catch (Throwable e) { Exceptions.throwIfFatal(e); cancel(); @@ -163,7 +162,7 @@ static final class PublisherBufferSkipSubscriber downstream; - final Callable bufferSupplier; + final Supplier bufferSupplier; final int size; @@ -178,7 +177,7 @@ static final class PublisherBufferSkipSubscriber actual, int size, int skip, - Callable bufferSupplier) { + Supplier bufferSupplier) { this.downstream = actual; this.size = size; this.skip = skip; @@ -228,7 +227,7 @@ public void onNext(T t) { if (i++ == 0) { try { - b = ObjectHelper.requireNonNull(bufferSupplier.call(), "The bufferSupplier returned a null buffer"); + b = ObjectHelper.requireNonNull(bufferSupplier.get(), "The bufferSupplier returned a null buffer"); } catch (Throwable e) { Exceptions.throwIfFatal(e); cancel(); @@ -293,7 +292,7 @@ static final class PublisherBufferOverlappingSubscriber downstream; - final Callable bufferSupplier; + final Supplier bufferSupplier; final int size; @@ -314,7 +313,7 @@ static final class PublisherBufferOverlappingSubscriber actual, int size, int skip, - Callable bufferSupplier) { + Supplier bufferSupplier) { this.downstream = actual; this.size = size; this.skip = skip; @@ -379,7 +378,7 @@ public void onNext(T t) { C b; try { - b = ObjectHelper.requireNonNull(bufferSupplier.call(), "The bufferSupplier returned a null buffer"); + b = ObjectHelper.requireNonNull(bufferSupplier.get(), "The bufferSupplier returned a null buffer"); } catch (Throwable e) { Exceptions.throwIfFatal(e); cancel(); diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableBufferBoundary.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableBufferBoundary.java index 44146a5829..3398e201f7 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableBufferBoundary.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableBufferBoundary.java @@ -14,7 +14,6 @@ package io.reactivex.internal.operators.flowable; import java.util.*; -import java.util.concurrent.Callable; import java.util.concurrent.atomic.*; import org.reactivestreams.*; @@ -22,7 +21,7 @@ import io.reactivex.*; import io.reactivex.disposables.*; import io.reactivex.exceptions.Exceptions; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.queue.SpscLinkedArrayQueue; import io.reactivex.internal.subscriptions.SubscriptionHelper; @@ -31,12 +30,12 @@ public final class FlowableBufferBoundary, Open, Close> extends AbstractFlowableWithUpstream { - final Callable bufferSupplier; + final Supplier bufferSupplier; final Publisher bufferOpen; final Function> bufferClose; public FlowableBufferBoundary(Flowable source, Publisher bufferOpen, - Function> bufferClose, Callable bufferSupplier) { + Function> bufferClose, Supplier bufferSupplier) { super(source); this.bufferOpen = bufferOpen; this.bufferClose = bufferClose; @@ -60,7 +59,7 @@ static final class BufferBoundarySubscriber, final Subscriber downstream; - final Callable bufferSupplier; + final Supplier bufferSupplier; final Publisher bufferOpen; @@ -89,7 +88,7 @@ static final class BufferBoundarySubscriber, BufferBoundarySubscriber(Subscriber actual, Publisher bufferOpen, Function> bufferClose, - Callable bufferSupplier + Supplier bufferSupplier ) { this.downstream = actual; this.bufferSupplier = bufferSupplier; @@ -184,7 +183,7 @@ void open(Open token) { Publisher p; C buf; try { - buf = ObjectHelper.requireNonNull(bufferSupplier.call(), "The bufferSupplier returned a null Collection"); + buf = ObjectHelper.requireNonNull(bufferSupplier.get(), "The bufferSupplier returned a null Collection"); p = ObjectHelper.requireNonNull(bufferClose.apply(token), "The bufferClose returned a null Publisher"); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableBufferBoundarySupplier.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableBufferBoundarySupplier.java index 8c544d958d..362acb9645 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableBufferBoundarySupplier.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableBufferBoundarySupplier.java @@ -14,7 +14,6 @@ package io.reactivex.internal.operators.flowable; import java.util.Collection; -import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicReference; import org.reactivestreams.*; @@ -22,6 +21,7 @@ import io.reactivex.*; import io.reactivex.disposables.Disposable; import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.Supplier; import io.reactivex.internal.disposables.DisposableHelper; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.queue.MpscLinkedQueue; @@ -33,10 +33,10 @@ public final class FlowableBufferBoundarySupplier, B> extends AbstractFlowableWithUpstream { - final Callable> boundarySupplier; - final Callable bufferSupplier; + final Supplier> boundarySupplier; + final Supplier bufferSupplier; - public FlowableBufferBoundarySupplier(Flowable source, Callable> boundarySupplier, Callable bufferSupplier) { + public FlowableBufferBoundarySupplier(Flowable source, Supplier> boundarySupplier, Supplier bufferSupplier) { super(source); this.boundarySupplier = boundarySupplier; this.bufferSupplier = bufferSupplier; @@ -50,8 +50,8 @@ protected void subscribeActual(Subscriber s) { static final class BufferBoundarySupplierSubscriber, B> extends QueueDrainSubscriber implements FlowableSubscriber, Subscription, Disposable { - final Callable bufferSupplier; - final Callable> boundarySupplier; + final Supplier bufferSupplier; + final Supplier> boundarySupplier; Subscription upstream; @@ -59,8 +59,8 @@ static final class BufferBoundarySupplierSubscriber actual, Callable bufferSupplier, - Callable> boundarySupplier) { + BufferBoundarySupplierSubscriber(Subscriber actual, Supplier bufferSupplier, + Supplier> boundarySupplier) { super(actual, new MpscLinkedQueue()); this.bufferSupplier = bufferSupplier; this.boundarySupplier = boundarySupplier; @@ -78,7 +78,7 @@ public void onSubscribe(Subscription s) { U b; try { - b = ObjectHelper.requireNonNull(bufferSupplier.call(), "The buffer supplied is null"); + b = ObjectHelper.requireNonNull(bufferSupplier.get(), "The buffer supplied is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); cancelled = true; @@ -92,7 +92,7 @@ public void onSubscribe(Subscription s) { Publisher boundary; try { - boundary = ObjectHelper.requireNonNull(boundarySupplier.call(), "The boundary publisher supplied is null"); + boundary = ObjectHelper.requireNonNull(boundarySupplier.get(), "The boundary publisher supplied is null"); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); cancelled = true; @@ -174,7 +174,7 @@ void next() { U next; try { - next = ObjectHelper.requireNonNull(bufferSupplier.call(), "The buffer supplied is null"); + next = ObjectHelper.requireNonNull(bufferSupplier.get(), "The buffer supplied is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); cancel(); @@ -185,7 +185,7 @@ void next() { Publisher boundary; try { - boundary = ObjectHelper.requireNonNull(boundarySupplier.call(), "The boundary publisher supplied is null"); + boundary = ObjectHelper.requireNonNull(boundarySupplier.get(), "The boundary publisher supplied is null"); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); cancelled = true; diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableBufferExactBoundary.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableBufferExactBoundary.java index 82215ae967..68d3f10018 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableBufferExactBoundary.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableBufferExactBoundary.java @@ -14,13 +14,13 @@ package io.reactivex.internal.operators.flowable; import java.util.Collection; -import java.util.concurrent.Callable; import org.reactivestreams.*; import io.reactivex.*; import io.reactivex.disposables.Disposable; import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.Supplier; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.queue.MpscLinkedQueue; import io.reactivex.internal.subscribers.QueueDrainSubscriber; @@ -31,9 +31,9 @@ public final class FlowableBufferExactBoundary, B> extends AbstractFlowableWithUpstream { final Publisher boundary; - final Callable bufferSupplier; + final Supplier bufferSupplier; - public FlowableBufferExactBoundary(Flowable source, Publisher boundary, Callable bufferSupplier) { + public FlowableBufferExactBoundary(Flowable source, Publisher boundary, Supplier bufferSupplier) { super(source); this.boundary = boundary; this.bufferSupplier = bufferSupplier; @@ -47,7 +47,7 @@ protected void subscribeActual(Subscriber s) { static final class BufferExactBoundarySubscriber, B> extends QueueDrainSubscriber implements FlowableSubscriber, Subscription, Disposable { - final Callable bufferSupplier; + final Supplier bufferSupplier; final Publisher boundary; Subscription upstream; @@ -56,7 +56,7 @@ static final class BufferExactBoundarySubscriber actual, Callable bufferSupplier, + BufferExactBoundarySubscriber(Subscriber actual, Supplier bufferSupplier, Publisher boundary) { super(actual, new MpscLinkedQueue()); this.bufferSupplier = bufferSupplier; @@ -73,7 +73,7 @@ public void onSubscribe(Subscription s) { U b; try { - b = ObjectHelper.requireNonNull(bufferSupplier.call(), "The buffer supplied is null"); + b = ObjectHelper.requireNonNull(bufferSupplier.get(), "The buffer supplied is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); cancelled = true; @@ -153,7 +153,7 @@ void next() { U next; try { - next = ObjectHelper.requireNonNull(bufferSupplier.call(), "The buffer supplied is null"); + next = ObjectHelper.requireNonNull(bufferSupplier.get(), "The buffer supplied is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); cancel(); diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableBufferTimed.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableBufferTimed.java index 06736603f1..b656c0a93e 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableBufferTimed.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableBufferTimed.java @@ -23,6 +23,7 @@ import io.reactivex.Scheduler.Worker; import io.reactivex.disposables.Disposable; import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.Supplier; import io.reactivex.internal.disposables.DisposableHelper; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.queue.MpscLinkedQueue; @@ -37,11 +38,11 @@ public final class FlowableBufferTimed> exten final long timeskip; final TimeUnit unit; final Scheduler scheduler; - final Callable bufferSupplier; + final Supplier bufferSupplier; final int maxSize; final boolean restartTimerOnMaxSize; - public FlowableBufferTimed(Flowable source, long timespan, long timeskip, TimeUnit unit, Scheduler scheduler, Callable bufferSupplier, int maxSize, + public FlowableBufferTimed(Flowable source, long timespan, long timeskip, TimeUnit unit, Scheduler scheduler, Supplier bufferSupplier, int maxSize, boolean restartTimerOnMaxSize) { super(source); this.timespan = timespan; @@ -80,7 +81,7 @@ protected void subscribeActual(Subscriber s) { static final class BufferExactUnboundedSubscriber> extends QueueDrainSubscriber implements Subscription, Runnable, Disposable { - final Callable bufferSupplier; + final Supplier bufferSupplier; final long timespan; final TimeUnit unit; final Scheduler scheduler; @@ -92,7 +93,7 @@ static final class BufferExactUnboundedSubscriber timer = new AtomicReference(); BufferExactUnboundedSubscriber( - Subscriber actual, Callable bufferSupplier, + Subscriber actual, Supplier bufferSupplier, long timespan, TimeUnit unit, Scheduler scheduler) { super(actual, new MpscLinkedQueue()); this.bufferSupplier = bufferSupplier; @@ -109,7 +110,7 @@ public void onSubscribe(Subscription s) { U b; try { - b = ObjectHelper.requireNonNull(bufferSupplier.call(), "The supplied buffer is null"); + b = ObjectHelper.requireNonNull(bufferSupplier.get(), "The supplied buffer is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); cancel(); @@ -186,7 +187,7 @@ public void run() { U next; try { - next = ObjectHelper.requireNonNull(bufferSupplier.call(), "The supplied buffer is null"); + next = ObjectHelper.requireNonNull(bufferSupplier.get(), "The supplied buffer is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); cancel(); @@ -226,7 +227,7 @@ public boolean isDisposed() { static final class BufferSkipBoundedSubscriber> extends QueueDrainSubscriber implements Subscription, Runnable { - final Callable bufferSupplier; + final Supplier bufferSupplier; final long timespan; final long timeskip; final TimeUnit unit; @@ -236,7 +237,7 @@ static final class BufferSkipBoundedSubscriber actual, - Callable bufferSupplier, long timespan, + Supplier bufferSupplier, long timespan, long timeskip, TimeUnit unit, Worker w) { super(actual, new MpscLinkedQueue()); this.bufferSupplier = bufferSupplier; @@ -257,7 +258,7 @@ public void onSubscribe(Subscription s) { final U b; // NOPMD try { - b = ObjectHelper.requireNonNull(bufferSupplier.call(), "The supplied buffer is null"); + b = ObjectHelper.requireNonNull(bufferSupplier.get(), "The supplied buffer is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); w.dispose(); @@ -338,7 +339,7 @@ public void run() { final U b; // NOPMD try { - b = ObjectHelper.requireNonNull(bufferSupplier.call(), "The supplied buffer is null"); + b = ObjectHelper.requireNonNull(bufferSupplier.get(), "The supplied buffer is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); cancel(); @@ -382,7 +383,7 @@ public void run() { static final class BufferExactBoundedSubscriber> extends QueueDrainSubscriber implements Subscription, Runnable, Disposable { - final Callable bufferSupplier; + final Supplier bufferSupplier; final long timespan; final TimeUnit unit; final int maxSize; @@ -401,7 +402,7 @@ static final class BufferExactBoundedSubscriber actual, - Callable bufferSupplier, + Supplier bufferSupplier, long timespan, TimeUnit unit, int maxSize, boolean restartOnMaxSize, Worker w) { super(actual, new MpscLinkedQueue()); @@ -423,7 +424,7 @@ public void onSubscribe(Subscription s) { U b; try { - b = ObjectHelper.requireNonNull(bufferSupplier.call(), "The supplied buffer is null"); + b = ObjectHelper.requireNonNull(bufferSupplier.get(), "The supplied buffer is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); w.dispose(); @@ -467,7 +468,7 @@ public void onNext(T t) { fastPathOrderedEmitMax(b, false, this); try { - b = ObjectHelper.requireNonNull(bufferSupplier.call(), "The supplied buffer is null"); + b = ObjectHelper.requireNonNull(bufferSupplier.get(), "The supplied buffer is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); cancel(); @@ -549,7 +550,7 @@ public void run() { U next; try { - next = ObjectHelper.requireNonNull(bufferSupplier.call(), "The supplied buffer is null"); + next = ObjectHelper.requireNonNull(bufferSupplier.get(), "The supplied buffer is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); cancel(); diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableCollect.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableCollect.java index ff858505a0..ea247ef56e 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableCollect.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableCollect.java @@ -12,23 +12,21 @@ */ package io.reactivex.internal.operators.flowable; -import java.util.concurrent.Callable; - import org.reactivestreams.*; import io.reactivex.*; import io.reactivex.exceptions.Exceptions; -import io.reactivex.functions.BiConsumer; +import io.reactivex.functions.*; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.subscriptions.*; import io.reactivex.plugins.RxJavaPlugins; public final class FlowableCollect extends AbstractFlowableWithUpstream { - final Callable initialSupplier; + final Supplier initialSupplier; final BiConsumer collector; - public FlowableCollect(Flowable source, Callable initialSupplier, BiConsumer collector) { + public FlowableCollect(Flowable source, Supplier initialSupplier, BiConsumer collector) { super(source); this.initialSupplier = initialSupplier; this.collector = collector; @@ -38,7 +36,7 @@ public FlowableCollect(Flowable source, Callable initialSupplier protected void subscribeActual(Subscriber s) { U u; try { - u = ObjectHelper.requireNonNull(initialSupplier.call(), "The initial value supplied is null"); + u = ObjectHelper.requireNonNull(initialSupplier.get(), "The initial value supplied is null"); } catch (Throwable e) { EmptySubscription.error(e, s); return; diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableCollectSingle.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableCollectSingle.java index c5d3dc188d..39d45a3872 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableCollectSingle.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableCollectSingle.java @@ -12,14 +12,12 @@ */ package io.reactivex.internal.operators.flowable; -import java.util.concurrent.Callable; - -import org.reactivestreams.*; +import org.reactivestreams.Subscription; import io.reactivex.*; import io.reactivex.disposables.Disposable; import io.reactivex.exceptions.Exceptions; -import io.reactivex.functions.BiConsumer; +import io.reactivex.functions.*; import io.reactivex.internal.disposables.EmptyDisposable; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.fuseable.FuseToFlowable; @@ -30,10 +28,10 @@ public final class FlowableCollectSingle extends Single implements Fuse final Flowable source; - final Callable initialSupplier; + final Supplier initialSupplier; final BiConsumer collector; - public FlowableCollectSingle(Flowable source, Callable initialSupplier, BiConsumer collector) { + public FlowableCollectSingle(Flowable source, Supplier initialSupplier, BiConsumer collector) { this.source = source; this.initialSupplier = initialSupplier; this.collector = collector; @@ -43,7 +41,7 @@ public FlowableCollectSingle(Flowable source, Callable initialSu protected void subscribeActual(SingleObserver observer) { U u; try { - u = ObjectHelper.requireNonNull(initialSupplier.call(), "The initialSupplier returned a null value"); + u = ObjectHelper.requireNonNull(initialSupplier.get(), "The initialSupplier returned a null value"); } catch (Throwable e) { EmptyDisposable.error(e, observer); return; diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableCombineLatest.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableCombineLatest.java index c690701fcf..9ff88699aa 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableCombineLatest.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableCombineLatest.java @@ -466,7 +466,7 @@ public int requestFusion(int requestedMode) { @Nullable @SuppressWarnings("unchecked") @Override - public R poll() throws Exception { + public R poll() throws Throwable { Object e = queue.poll(); if (e == null) { return null; @@ -550,7 +550,7 @@ public void requestOne() { final class SingletonArrayFunc implements Function { @Override - public R apply(T t) throws Exception { + public R apply(T t) throws Throwable { return combiner.apply(new Object[] { t }); } } diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableConcatMap.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableConcatMap.java index 2dc316d1e9..7fac04d17c 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableConcatMap.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableConcatMap.java @@ -12,14 +12,13 @@ */ package io.reactivex.internal.operators.flowable; -import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicInteger; import org.reactivestreams.*; import io.reactivex.*; import io.reactivex.exceptions.Exceptions; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.fuseable.*; import io.reactivex.internal.queue.SpscArrayQueue; @@ -301,14 +300,14 @@ void drain() { } } - if (p instanceof Callable) { + if (p instanceof Supplier) { @SuppressWarnings("unchecked") - Callable callable = (Callable) p; + Supplier supplier = (Supplier) p; R vr; try { - vr = callable.call(); + vr = supplier.get(); } catch (Throwable e) { Exceptions.throwIfFatal(e); upstream.cancel(); @@ -510,14 +509,14 @@ void drain() { } } - if (p instanceof Callable) { + if (p instanceof Supplier) { @SuppressWarnings("unchecked") - Callable supplier = (Callable) p; + Supplier supplier = (Supplier) p; R vr; try { - vr = supplier.call(); + vr = supplier.get(); } catch (Throwable e) { Exceptions.throwIfFatal(e); upstream.cancel(); diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableDefer.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableDefer.java index 7ac266001f..3ff5a18a3e 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableDefer.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableDefer.java @@ -13,18 +13,17 @@ package io.reactivex.internal.operators.flowable; -import java.util.concurrent.Callable; - import org.reactivestreams.*; import io.reactivex.Flowable; import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.Supplier; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.subscriptions.EmptySubscription; public final class FlowableDefer extends Flowable { - final Callable> supplier; - public FlowableDefer(Callable> supplier) { + final Supplier> supplier; + public FlowableDefer(Supplier> supplier) { this.supplier = supplier; } @@ -32,7 +31,7 @@ public FlowableDefer(Callable> supplier) { public void subscribeActual(Subscriber s) { Publisher pub; try { - pub = ObjectHelper.requireNonNull(supplier.call(), "The publisher supplied is null"); + pub = ObjectHelper.requireNonNull(supplier.get(), "The publisher supplied is null"); } catch (Throwable t) { Exceptions.throwIfFatal(t); EmptySubscription.error(t, s); diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableDistinct.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableDistinct.java index 4e9bc5e1bf..860025040b 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableDistinct.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableDistinct.java @@ -14,14 +14,13 @@ package io.reactivex.internal.operators.flowable; import java.util.Collection; -import java.util.concurrent.Callable; import org.reactivestreams.Subscriber; import io.reactivex.Flowable; import io.reactivex.annotations.Nullable; import io.reactivex.exceptions.Exceptions; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.fuseable.QueueFuseable; import io.reactivex.internal.subscribers.BasicFuseableSubscriber; @@ -32,9 +31,9 @@ public final class FlowableDistinct extends AbstractFlowableWithUpstream keySelector; - final Callable> collectionSupplier; + final Supplier> collectionSupplier; - public FlowableDistinct(Flowable source, Function keySelector, Callable> collectionSupplier) { + public FlowableDistinct(Flowable source, Function keySelector, Supplier> collectionSupplier) { super(source); this.keySelector = keySelector; this.collectionSupplier = collectionSupplier; @@ -45,7 +44,7 @@ protected void subscribeActual(Subscriber subscriber) { Collection collection; try { - collection = ObjectHelper.requireNonNull(collectionSupplier.call(), "The collectionSupplier returned a null collection. Null values are generally not allowed in 2.x operators and sources."); + collection = ObjectHelper.requireNonNull(collectionSupplier.get(), "The collectionSupplier returned a null collection. Null values are generally not allowed in 2.x operators and sources."); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); EmptySubscription.error(ex, subscriber); @@ -121,7 +120,7 @@ public int requestFusion(int mode) { @Nullable @Override - public T poll() throws Exception { + public T poll() throws Throwable { for (;;) { T v = qs.poll(); diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableDistinctUntilChanged.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableDistinctUntilChanged.java index c1cf54658e..4d4061a99e 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableDistinctUntilChanged.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableDistinctUntilChanged.java @@ -109,7 +109,7 @@ public int requestFusion(int mode) { @Nullable @Override - public T poll() throws Exception { + public T poll() throws Throwable { for (;;) { T v = qs.poll(); if (v == null) { @@ -199,7 +199,7 @@ public int requestFusion(int mode) { @Nullable @Override - public T poll() throws Exception { + public T poll() throws Throwable { for (;;) { T v = qs.poll(); if (v == null) { diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableDoAfterNext.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableDoAfterNext.java index 968c589e2c..378c01cf15 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableDoAfterNext.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableDoAfterNext.java @@ -77,7 +77,7 @@ public int requestFusion(int mode) { @Nullable @Override - public T poll() throws Exception { + public T poll() throws Throwable { T v = qs.poll(); if (v != null) { onAfterNext.accept(v); @@ -126,7 +126,7 @@ public int requestFusion(int mode) { @Nullable @Override - public T poll() throws Exception { + public T poll() throws Throwable { T v = qs.poll(); if (v != null) { onAfterNext.accept(v); diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableDoFinally.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableDoFinally.java index 023c55bf7f..e6fbadd304 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableDoFinally.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableDoFinally.java @@ -132,7 +132,7 @@ public boolean isEmpty() { @Nullable @Override - public T poll() throws Exception { + public T poll() throws Throwable { T v = qs.poll(); if (v == null && syncFused) { runFinally(); @@ -242,7 +242,7 @@ public boolean isEmpty() { @Nullable @Override - public T poll() throws Exception { + public T poll() throws Throwable { T v = qs.poll(); if (v == null && syncFused) { runFinally(); diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableDoOnEach.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableDoOnEach.java index e913675f69..0d8a63b19e 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableDoOnEach.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableDoOnEach.java @@ -149,7 +149,7 @@ public int requestFusion(int mode) { @Nullable @Override - public T poll() throws Exception { + public T poll() throws Throwable { T v; try { @@ -304,7 +304,7 @@ public int requestFusion(int mode) { @Nullable @Override - public T poll() throws Exception { + public T poll() throws Throwable { T v; try { diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableEmpty.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableEmpty.java index dafd417143..bc5bf36e81 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableEmpty.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableEmpty.java @@ -16,13 +16,13 @@ import org.reactivestreams.Subscriber; import io.reactivex.Flowable; -import io.reactivex.internal.fuseable.ScalarCallable; +import io.reactivex.internal.fuseable.ScalarSupplier; import io.reactivex.internal.subscriptions.EmptySubscription; /** * A source Flowable that signals an onSubscribe() + onComplete() only. */ -public final class FlowableEmpty extends Flowable implements ScalarCallable { +public final class FlowableEmpty extends Flowable implements ScalarSupplier { public static final Flowable INSTANCE = new FlowableEmpty(); @@ -35,7 +35,7 @@ public void subscribeActual(Subscriber s) { } @Override - public Object call() { + public Object get() { return null; // null scalar is interpreted as being empty } } diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableError.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableError.java index dc88f01d7e..2580ecfb43 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableError.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableError.java @@ -13,18 +13,17 @@ package io.reactivex.internal.operators.flowable; -import java.util.concurrent.Callable; - import org.reactivestreams.Subscriber; import io.reactivex.Flowable; import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.Supplier; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.subscriptions.EmptySubscription; public final class FlowableError extends Flowable { - final Callable errorSupplier; - public FlowableError(Callable errorSupplier) { + final Supplier errorSupplier; + public FlowableError(Supplier errorSupplier) { this.errorSupplier = errorSupplier; } @@ -32,7 +31,7 @@ public FlowableError(Callable errorSupplier) { public void subscribeActual(Subscriber s) { Throwable error; try { - error = ObjectHelper.requireNonNull(errorSupplier.call(), "Callable returned null throwable. Null values are generally not allowed in 2.x operators and sources."); + error = ObjectHelper.requireNonNull(errorSupplier.get(), "Callable returned null throwable. Null values are generally not allowed in 2.x operators and sources."); } catch (Throwable t) { Exceptions.throwIfFatal(t); error = t; diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableFilter.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableFilter.java index dd90b2c1ec..aeeb21b799 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableFilter.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableFilter.java @@ -83,7 +83,7 @@ public int requestFusion(int mode) { @Nullable @Override - public T poll() throws Exception { + public T poll() throws Throwable { QueueSubscription qs = this.qs; Predicate f = filter; @@ -146,7 +146,7 @@ public int requestFusion(int mode) { @Nullable @Override - public T poll() throws Exception { + public T poll() throws Throwable { QueueSubscription qs = this.qs; Predicate f = filter; diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableFlatMap.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableFlatMap.java index c68e82bb93..099b3f6d52 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableFlatMap.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableFlatMap.java @@ -13,7 +13,6 @@ package io.reactivex.internal.operators.flowable; -import java.util.concurrent.Callable; import java.util.concurrent.atomic.*; import org.reactivestreams.*; @@ -21,7 +20,7 @@ import io.reactivex.*; import io.reactivex.disposables.Disposable; import io.reactivex.exceptions.*; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.fuseable.*; import io.reactivex.internal.queue.*; @@ -136,11 +135,11 @@ public void onNext(T t) { onError(e); return; } - if (p instanceof Callable) { + if (p instanceof Supplier) { U u; try { - u = ((Callable)p).call(); + u = ((Supplier)p).get(); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); errs.addThrowable(ex); diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableFlattenIterable.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableFlattenIterable.java index 01398b9a29..24b4b5237c 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableFlattenIterable.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableFlattenIterable.java @@ -14,7 +14,6 @@ package io.reactivex.internal.operators.flowable; import java.util.Iterator; -import java.util.concurrent.Callable; import java.util.concurrent.atomic.*; import org.reactivestreams.*; @@ -22,7 +21,7 @@ import io.reactivex.*; import io.reactivex.annotations.Nullable; import io.reactivex.exceptions.*; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.fuseable.*; import io.reactivex.internal.queue.SpscArrayQueue; @@ -46,11 +45,11 @@ public FlowableFlattenIterable(Flowable source, @SuppressWarnings("unchecked") @Override public void subscribeActual(Subscriber s) { - if (source instanceof Callable) { + if (source instanceof Supplier) { T v; try { - v = ((Callable)source).call(); + v = ((Supplier)source).get(); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); EmptySubscription.error(ex, s); @@ -415,7 +414,7 @@ public boolean isEmpty() { @Nullable @Override - public R poll() throws Exception { + public R poll() throws Throwable { Iterator it = current; for (;;) { if (it == null) { diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableGenerate.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableGenerate.java index 17bdd790b9..51f6d78996 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableGenerate.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableGenerate.java @@ -13,7 +13,6 @@ package io.reactivex.internal.operators.flowable; -import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicLong; import org.reactivestreams.*; @@ -26,11 +25,11 @@ import io.reactivex.plugins.RxJavaPlugins; public final class FlowableGenerate extends Flowable { - final Callable stateSupplier; + final Supplier stateSupplier; final BiFunction, S> generator; final Consumer disposeState; - public FlowableGenerate(Callable stateSupplier, BiFunction, S> generator, + public FlowableGenerate(Supplier stateSupplier, BiFunction, S> generator, Consumer disposeState) { this.stateSupplier = stateSupplier; this.generator = generator; @@ -42,7 +41,7 @@ public void subscribeActual(Subscriber s) { S state; try { - state = stateSupplier.call(); + state = stateSupplier.get(); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptySubscription.error(e, s); diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableGroupBy.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableGroupBy.java index 719645afe9..13941b6516 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableGroupBy.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableGroupBy.java @@ -67,7 +67,7 @@ protected void subscribeActual(Subscriber> s) { Consumer evictionAction = (Consumer) new EvictionAction(evictedGroups); groups = (Map) mapFactory.apply(evictionAction); } - } catch (Exception e) { + } catch (Throwable e) { Exceptions.throwIfFatal(e); s.onSubscribe(EmptyComponent.INSTANCE); s.onError(e); diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableInternalHelper.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableInternalHelper.java index d516b02ab0..936bfbb0a0 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableInternalHelper.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableInternalHelper.java @@ -40,7 +40,7 @@ static final class SimpleGenerator implements BiFunction, S> } @Override - public S apply(S t1, Emitter t2) throws Exception { + public S apply(S t1, Emitter t2) throws Throwable { consumer.accept(t2); return t1; } @@ -58,7 +58,7 @@ static final class SimpleBiGenerator implements BiFunction, } @Override - public S apply(S t1, Emitter t2) throws Exception { + public S apply(S t1, Emitter t2) throws Throwable { consumer.accept(t1, t2); return t1; } @@ -76,7 +76,7 @@ static final class ItemDelayFunction implements Function> } @Override - public Publisher apply(final T v) throws Exception { + public Publisher apply(final T v) throws Throwable { Publisher p = ObjectHelper.requireNonNull(itemDelay.apply(v), "The itemDelay returned a null Publisher"); return new FlowableTakePublisher(p, 1).map(Functions.justFunction(v)).defaultIfEmpty(v); } @@ -147,7 +147,7 @@ static final class FlatMapWithCombinerInner implements Function { } @Override - public R apply(U w) throws Exception { + public R apply(U w) throws Throwable { return combiner.apply(t, w); } } @@ -163,7 +163,7 @@ static final class FlatMapWithCombinerOuter implements Function apply(final T t) throws Exception { + public Publisher apply(final T t) throws Throwable { @SuppressWarnings("unchecked") Publisher u = (Publisher)ObjectHelper.requireNonNull(mapper.apply(t), "The mapper returned a null Publisher"); return new FlowableMapPublisher(u, new FlatMapWithCombinerInner(combiner, t)); @@ -184,7 +184,7 @@ static final class FlatMapIntoIterable implements Function } @Override - public Publisher apply(T t) throws Exception { + public Publisher apply(T t) throws Throwable { return new FlowableFromIterable(ObjectHelper.requireNonNull(mapper.apply(t), "The mapper returned a null Iterable")); } } @@ -193,19 +193,19 @@ public static Function> flatMapIntoIterable(final Functio return new FlatMapIntoIterable(mapper); } - public static Callable> replayCallable(final Flowable parent) { - return new ReplayCallable(parent); + public static Supplier> replaySupplier(final Flowable parent) { + return new ReplaySupplier(parent); } - public static Callable> replayCallable(final Flowable parent, final int bufferSize) { - return new BufferedReplayCallable(parent, bufferSize); + public static Supplier> replaySupplier(final Flowable parent, final int bufferSize) { + return new BufferedReplaySupplier(parent, bufferSize); } - public static Callable> replayCallable(final Flowable parent, final int bufferSize, final long time, final TimeUnit unit, final Scheduler scheduler) { + public static Supplier> replaySupplier(final Flowable parent, final int bufferSize, final long time, final TimeUnit unit, final Scheduler scheduler) { return new BufferedTimedReplay(parent, bufferSize, time, unit, scheduler); } - public static Callable> replayCallable(final Flowable parent, final long time, final TimeUnit unit, final Scheduler scheduler) { + public static Supplier> replaySupplier(final Flowable parent, final long time, final TimeUnit unit, final Scheduler scheduler) { return new TimedReplay(parent, time, unit, scheduler); } @@ -239,35 +239,35 @@ public static Function>, Publisher(zipper); } - static final class ReplayCallable implements Callable> { + static final class ReplaySupplier implements Supplier> { private final Flowable parent; - ReplayCallable(Flowable parent) { + ReplaySupplier(Flowable parent) { this.parent = parent; } @Override - public ConnectableFlowable call() { + public ConnectableFlowable get() { return parent.replay(); } } - static final class BufferedReplayCallable implements Callable> { + static final class BufferedReplaySupplier implements Supplier> { private final Flowable parent; private final int bufferSize; - BufferedReplayCallable(Flowable parent, int bufferSize) { + BufferedReplaySupplier(Flowable parent, int bufferSize) { this.parent = parent; this.bufferSize = bufferSize; } @Override - public ConnectableFlowable call() { + public ConnectableFlowable get() { return parent.replay(bufferSize); } } - static final class BufferedTimedReplay implements Callable> { + static final class BufferedTimedReplay implements Supplier> { private final Flowable parent; private final int bufferSize; private final long time; @@ -283,12 +283,12 @@ static final class BufferedTimedReplay implements Callable call() { + public ConnectableFlowable get() { return parent.replay(bufferSize, time, unit, scheduler); } } - static final class TimedReplay implements Callable> { + static final class TimedReplay implements Supplier> { private final Flowable parent; private final long time; private final TimeUnit unit; @@ -302,7 +302,7 @@ static final class TimedReplay implements Callable> { } @Override - public ConnectableFlowable call() { + public ConnectableFlowable get() { return parent.replay(time, unit, scheduler); } } @@ -317,7 +317,7 @@ static final class ReplayFunction implements Function, Publish } @Override - public Publisher apply(Flowable t) throws Exception { + public Publisher apply(Flowable t) throws Throwable { Publisher p = ObjectHelper.requireNonNull(selector.apply(t), "The selector returned a null Publisher"); return Flowable.fromPublisher(p).observeOn(scheduler); } diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableJust.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableJust.java index 5a07771872..d243fbb744 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableJust.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableJust.java @@ -16,14 +16,14 @@ import org.reactivestreams.Subscriber; import io.reactivex.Flowable; -import io.reactivex.internal.fuseable.ScalarCallable; +import io.reactivex.internal.fuseable.ScalarSupplier; import io.reactivex.internal.subscriptions.ScalarSubscription; /** * Represents a constant scalar value. * @param the value type */ -public final class FlowableJust extends Flowable implements ScalarCallable { +public final class FlowableJust extends Flowable implements ScalarSupplier { private final T value; public FlowableJust(final T value) { this.value = value; @@ -35,7 +35,7 @@ protected void subscribeActual(Subscriber s) { } @Override - public T call() { + public T get() { return value; } } diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableMap.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableMap.java index 7b6632dcf9..83d9cc79f1 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableMap.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableMap.java @@ -75,7 +75,7 @@ public int requestFusion(int mode) { @Nullable @Override - public U poll() throws Exception { + public U poll() throws Throwable { T t = qs.poll(); return t != null ? ObjectHelper.requireNonNull(mapper.apply(t), "The mapper function returned a null value.") : null; } @@ -135,7 +135,7 @@ public int requestFusion(int mode) { @Nullable @Override - public U poll() throws Exception { + public U poll() throws Throwable { T t = qs.poll(); return t != null ? ObjectHelper.requireNonNull(mapper.apply(t), "The mapper function returned a null value.") : null; } diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableMapNotification.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableMapNotification.java index 4b90d60ea3..8f9932442e 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableMapNotification.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableMapNotification.java @@ -13,13 +13,11 @@ package io.reactivex.internal.operators.flowable; -import java.util.concurrent.Callable; - import org.reactivestreams.Subscriber; import io.reactivex.Flowable; import io.reactivex.exceptions.*; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.subscribers.SinglePostCompleteSubscriber; @@ -27,13 +25,13 @@ public final class FlowableMapNotification extends AbstractFlowableWithUps final Function onNextMapper; final Function onErrorMapper; - final Callable onCompleteSupplier; + final Supplier onCompleteSupplier; public FlowableMapNotification( Flowable source, Function onNextMapper, Function onErrorMapper, - Callable onCompleteSupplier) { + Supplier onCompleteSupplier) { super(source); this.onNextMapper = onNextMapper; this.onErrorMapper = onErrorMapper; @@ -51,12 +49,12 @@ static final class MapNotificationSubscriber private static final long serialVersionUID = 2757120512858778108L; final Function onNextMapper; final Function onErrorMapper; - final Callable onCompleteSupplier; + final Supplier onCompleteSupplier; MapNotificationSubscriber(Subscriber actual, Function onNextMapper, Function onErrorMapper, - Callable onCompleteSupplier) { + Supplier onCompleteSupplier) { super(actual); this.onNextMapper = onNextMapper; this.onErrorMapper = onErrorMapper; @@ -99,7 +97,7 @@ public void onComplete() { R p; try { - p = ObjectHelper.requireNonNull(onCompleteSupplier.call(), "The onComplete publisher returned is null"); + p = ObjectHelper.requireNonNull(onCompleteSupplier.get(), "The onComplete publisher returned is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); downstream.onError(e); diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableObserveOn.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableObserveOn.java index 2a7d499d1a..2053368ab6 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableObserveOn.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableObserveOn.java @@ -468,7 +468,7 @@ void runBackfused() { @Nullable @Override - public T poll() throws Exception { + public T poll() throws Throwable { T v = queue.poll(); if (v != null && sourceMode != SYNC) { long p = produced + 1; @@ -712,7 +712,7 @@ void runBackfused() { @Nullable @Override - public T poll() throws Exception { + public T poll() throws Throwable { T v = queue.poll(); if (v != null && sourceMode != SYNC) { long p = consumed + 1; diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableReduceWithSingle.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableReduceWithSingle.java index 321f27446d..e814658522 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableReduceWithSingle.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableReduceWithSingle.java @@ -13,13 +13,11 @@ package io.reactivex.internal.operators.flowable; -import java.util.concurrent.Callable; - import org.reactivestreams.Publisher; import io.reactivex.*; import io.reactivex.exceptions.Exceptions; -import io.reactivex.functions.BiFunction; +import io.reactivex.functions.*; import io.reactivex.internal.disposables.EmptyDisposable; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.operators.flowable.FlowableReduceSeedSingle.ReduceSeedObserver; @@ -35,11 +33,11 @@ public final class FlowableReduceWithSingle extends Single { final Publisher source; - final Callable seedSupplier; + final Supplier seedSupplier; final BiFunction reducer; - public FlowableReduceWithSingle(Publisher source, Callable seedSupplier, BiFunction reducer) { + public FlowableReduceWithSingle(Publisher source, Supplier seedSupplier, BiFunction reducer) { this.source = source; this.seedSupplier = seedSupplier; this.reducer = reducer; @@ -50,7 +48,7 @@ protected void subscribeActual(SingleObserver observer) { R seed; try { - seed = ObjectHelper.requireNonNull(seedSupplier.call(), "The seedSupplier returned a null value"); + seed = ObjectHelper.requireNonNull(seedSupplier.get(), "The seedSupplier returned a null value"); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); EmptyDisposable.error(ex, observer); diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableReplay.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableReplay.java index 7a02482b4b..1acd6bfad8 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableReplay.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableReplay.java @@ -39,12 +39,12 @@ public final class FlowableReplay extends ConnectableFlowable implements H /** Holds the current subscriber that is, will be or just was subscribed to the source observable. */ final AtomicReference> current; /** A factory that creates the appropriate buffer for the ReplaySubscriber. */ - final Callable> bufferFactory; + final Supplier> bufferFactory; final Publisher onSubscribe; @SuppressWarnings("rawtypes") - static final Callable DEFAULT_UNBOUNDED_FACTORY = new DefaultUnboundedFactory(); + static final Supplier DEFAULT_UNBOUNDED_FACTORY = new DefaultUnboundedFactory(); /** * Given a connectable observable factory, it multicasts over the generated @@ -56,7 +56,7 @@ public final class FlowableReplay extends ConnectableFlowable implements H * @return the new Observable instance */ public static Flowable multicastSelector( - final Callable> connectableFactory, + final Supplier> connectableFactory, final Function, ? extends Publisher> selector) { return new MulticastFlowable(connectableFactory, selector); } @@ -136,7 +136,7 @@ public static ConnectableFlowable create(Flowable source, * @return the connectable observable */ static ConnectableFlowable create(Flowable source, - final Callable> bufferFactory) { + final Supplier> bufferFactory) { // the current connection to source needs to be shared between the operator and its onSubscribe call final AtomicReference> curr = new AtomicReference>(); Publisher onSubscribe = new ReplayPublisher(curr, bufferFactory); @@ -145,7 +145,7 @@ static ConnectableFlowable create(Flowable source, private FlowableReplay(Publisher onSubscribe, Flowable source, final AtomicReference> current, - final Callable> bufferFactory) { + final Supplier> bufferFactory) { this.onSubscribe = onSubscribe; this.source = source; this.current = current; @@ -182,7 +182,7 @@ public void connect(Consumer connection) { ReplayBuffer buf; try { - buf = bufferFactory.call(); + buf = bufferFactory.get(); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); throw ExceptionHelper.wrapOrThrow(ex); @@ -1093,10 +1093,10 @@ Node getHead() { } static final class MulticastFlowable extends Flowable { - private final Callable> connectableFactory; + private final Supplier> connectableFactory; private final Function, ? extends Publisher> selector; - MulticastFlowable(Callable> connectableFactory, Function, ? extends Publisher> selector) { + MulticastFlowable(Supplier> connectableFactory, Function, ? extends Publisher> selector) { this.connectableFactory = connectableFactory; this.selector = selector; } @@ -1105,7 +1105,7 @@ static final class MulticastFlowable extends Flowable { protected void subscribeActual(Subscriber child) { ConnectableFlowable cf; try { - cf = ObjectHelper.requireNonNull(connectableFactory.call(), "The connectableFactory returned null"); + cf = ObjectHelper.requireNonNull(connectableFactory.get(), "The connectableFactory returned null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptySubscription.error(e, child); @@ -1162,7 +1162,7 @@ protected void subscribeActual(Subscriber s) { } } - static final class ReplayBufferTask implements Callable> { + static final class ReplayBufferTask implements Supplier> { private final int bufferSize; ReplayBufferTask(int bufferSize) { @@ -1170,12 +1170,12 @@ static final class ReplayBufferTask implements Callable> { } @Override - public ReplayBuffer call() { + public ReplayBuffer get() { return new SizeBoundReplayBuffer(bufferSize); } } - static final class ScheduledReplayBufferTask implements Callable> { + static final class ScheduledReplayBufferTask implements Supplier> { private final int bufferSize; private final long maxAge; private final TimeUnit unit; @@ -1189,16 +1189,16 @@ static final class ScheduledReplayBufferTask implements Callable call() { + public ReplayBuffer get() { return new SizeAndTimeBoundReplayBuffer(bufferSize, maxAge, unit, scheduler); } } static final class ReplayPublisher implements Publisher { private final AtomicReference> curr; - private final Callable> bufferFactory; + private final Supplier> bufferFactory; - ReplayPublisher(AtomicReference> curr, Callable> bufferFactory) { + ReplayPublisher(AtomicReference> curr, Supplier> bufferFactory) { this.curr = curr; this.bufferFactory = bufferFactory; } @@ -1215,7 +1215,7 @@ public void subscribe(Subscriber child) { ReplayBuffer buf; try { - buf = bufferFactory.call(); + buf = bufferFactory.get(); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); EmptySubscription.error(ex, child); @@ -1260,9 +1260,9 @@ public void subscribe(Subscriber child) { } } - static final class DefaultUnboundedFactory implements Callable { + static final class DefaultUnboundedFactory implements Supplier { @Override - public Object call() { + public Object get() { return new UnboundedReplayBuffer(16); } } diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableScalarXMap.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableScalarXMap.java index 1acf93f174..8a9903ec4c 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableScalarXMap.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableScalarXMap.java @@ -13,13 +13,11 @@ package io.reactivex.internal.operators.flowable; -import java.util.concurrent.Callable; - import org.reactivestreams.*; import io.reactivex.Flowable; import io.reactivex.exceptions.Exceptions; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.subscriptions.*; import io.reactivex.plugins.RxJavaPlugins; @@ -35,7 +33,7 @@ private FlowableScalarXMap() { } /** - * Tries to subscribe to a possibly Callable source's mapped Publisher. + * Tries to subscribe to a possibly Supplier source's mapped Publisher. * @param the input value type * @param the output value type * @param source the source Publisher @@ -47,11 +45,11 @@ private FlowableScalarXMap() { public static boolean tryScalarXMapSubscribe(Publisher source, Subscriber subscriber, Function> mapper) { - if (source instanceof Callable) { + if (source instanceof Supplier) { T t; try { - t = ((Callable)source).call(); + t = ((Supplier)source).get(); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); EmptySubscription.error(ex, subscriber); @@ -73,11 +71,11 @@ public static boolean tryScalarXMapSubscribe(Publisher source, return true; } - if (r instanceof Callable) { + if (r instanceof Supplier) { R u; try { - u = ((Callable)r).call(); + u = ((Supplier)r).get(); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); EmptySubscription.error(ex, subscriber); @@ -140,11 +138,11 @@ public void subscribeActual(Subscriber s) { EmptySubscription.error(e, s); return; } - if (other instanceof Callable) { + if (other instanceof Supplier) { R u; try { - u = ((Callable)other).call(); + u = ((Supplier)other).get(); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); EmptySubscription.error(ex, s); diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableScanSeed.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableScanSeed.java index 6586b55253..13272256d7 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableScanSeed.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableScanSeed.java @@ -12,14 +12,13 @@ */ package io.reactivex.internal.operators.flowable; -import java.util.concurrent.Callable; import java.util.concurrent.atomic.*; import org.reactivestreams.*; import io.reactivex.*; import io.reactivex.exceptions.Exceptions; -import io.reactivex.functions.BiFunction; +import io.reactivex.functions.*; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.fuseable.SimplePlainQueue; import io.reactivex.internal.queue.SpscArrayQueue; @@ -29,9 +28,9 @@ public final class FlowableScanSeed extends AbstractFlowableWithUpstream { final BiFunction accumulator; - final Callable seedSupplier; + final Supplier seedSupplier; - public FlowableScanSeed(Flowable source, Callable seedSupplier, BiFunction accumulator) { + public FlowableScanSeed(Flowable source, Supplier seedSupplier, BiFunction accumulator) { super(source); this.accumulator = accumulator; this.seedSupplier = seedSupplier; @@ -42,7 +41,7 @@ protected void subscribeActual(Subscriber s) { R r; try { - r = ObjectHelper.requireNonNull(seedSupplier.call(), "The seed supplied is null"); + r = ObjectHelper.requireNonNull(seedSupplier.get(), "The seed supplied is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptySubscription.error(e, s); diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableToList.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableToList.java index 60508e3e7e..3b0daf30cd 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableToList.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableToList.java @@ -14,19 +14,19 @@ package io.reactivex.internal.operators.flowable; import java.util.Collection; -import java.util.concurrent.Callable; import org.reactivestreams.*; import io.reactivex.*; import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.Supplier; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.subscriptions.*; public final class FlowableToList> extends AbstractFlowableWithUpstream { - final Callable collectionSupplier; + final Supplier collectionSupplier; - public FlowableToList(Flowable source, Callable collectionSupplier) { + public FlowableToList(Flowable source, Supplier collectionSupplier) { super(source); this.collectionSupplier = collectionSupplier; } @@ -35,7 +35,7 @@ public FlowableToList(Flowable source, Callable collectionSupplier) { protected void subscribeActual(Subscriber s) { U coll; try { - coll = ObjectHelper.requireNonNull(collectionSupplier.call(), "The collectionSupplier returned a null collection. Null values are generally not allowed in 2.x operators and sources."); + coll = ObjectHelper.requireNonNull(collectionSupplier.get(), "The collectionSupplier returned a null collection. Null values are generally not allowed in 2.x operators and sources."); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptySubscription.error(e, s); diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableToListSingle.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableToListSingle.java index e4a8abd565..bd5b02073b 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableToListSingle.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableToListSingle.java @@ -14,13 +14,13 @@ package io.reactivex.internal.operators.flowable; import java.util.Collection; -import java.util.concurrent.Callable; import org.reactivestreams.Subscription; import io.reactivex.*; import io.reactivex.disposables.Disposable; import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.Supplier; import io.reactivex.internal.disposables.EmptyDisposable; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.fuseable.FuseToFlowable; @@ -32,14 +32,14 @@ public final class FlowableToListSingle> exte final Flowable source; - final Callable collectionSupplier; + final Supplier collectionSupplier; @SuppressWarnings("unchecked") public FlowableToListSingle(Flowable source) { - this(source, (Callable)ArrayListSupplier.asCallable()); + this(source, (Supplier)ArrayListSupplier.asSupplier()); } - public FlowableToListSingle(Flowable source, Callable collectionSupplier) { + public FlowableToListSingle(Flowable source, Supplier collectionSupplier) { this.source = source; this.collectionSupplier = collectionSupplier; } @@ -48,7 +48,7 @@ public FlowableToListSingle(Flowable source, Callable collectionSupplier) protected void subscribeActual(SingleObserver observer) { U coll; try { - coll = ObjectHelper.requireNonNull(collectionSupplier.call(), "The collectionSupplier returned a null collection. Null values are generally not allowed in 2.x operators and sources."); + coll = ObjectHelper.requireNonNull(collectionSupplier.get(), "The collectionSupplier returned a null collection. Null values are generally not allowed in 2.x operators and sources."); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptyDisposable.error(e, observer); diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableUsing.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableUsing.java index 2d3a83fc4a..26cc516de2 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableUsing.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableUsing.java @@ -13,7 +13,6 @@ package io.reactivex.internal.operators.flowable; -import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicBoolean; import org.reactivestreams.*; @@ -26,12 +25,12 @@ import io.reactivex.plugins.RxJavaPlugins; public final class FlowableUsing extends Flowable { - final Callable resourceSupplier; + final Supplier resourceSupplier; final Function> sourceSupplier; final Consumer disposer; final boolean eager; - public FlowableUsing(Callable resourceSupplier, + public FlowableUsing(Supplier resourceSupplier, Function> sourceSupplier, Consumer disposer, boolean eager) { @@ -46,7 +45,7 @@ public void subscribeActual(Subscriber s) { D resource; try { - resource = resourceSupplier.call(); + resource = resourceSupplier.get(); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptySubscription.error(e, s); diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableWindowBoundarySupplier.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableWindowBoundarySupplier.java index f82c56a889..50ddca4e22 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableWindowBoundarySupplier.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableWindowBoundarySupplier.java @@ -13,7 +13,6 @@ package io.reactivex.internal.operators.flowable; -import java.util.concurrent.Callable; import java.util.concurrent.atomic.*; import org.reactivestreams.*; @@ -21,6 +20,7 @@ import io.reactivex.*; import io.reactivex.disposables.Disposable; import io.reactivex.exceptions.*; +import io.reactivex.functions.Supplier; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.queue.MpscLinkedQueue; import io.reactivex.internal.subscriptions.SubscriptionHelper; @@ -30,11 +30,11 @@ import io.reactivex.subscribers.DisposableSubscriber; public final class FlowableWindowBoundarySupplier extends AbstractFlowableWithUpstream> { - final Callable> other; + final Supplier> other; final int capacityHint; public FlowableWindowBoundarySupplier(Flowable source, - Callable> other, int capacityHint) { + Supplier> other, int capacityHint) { super(source); this.other = other; this.capacityHint = capacityHint; @@ -69,7 +69,7 @@ static final class WindowBoundaryMainSubscriber final AtomicBoolean stopWindows; - final Callable> other; + final Supplier> other; static final Object NEXT_WINDOW = new Object(); @@ -83,7 +83,7 @@ static final class WindowBoundaryMainSubscriber long emitted; - WindowBoundaryMainSubscriber(Subscriber> downstream, int capacityHint, Callable> other) { + WindowBoundaryMainSubscriber(Subscriber> downstream, int capacityHint, Supplier> other) { this.downstream = downstream; this.capacityHint = capacityHint; this.boundarySubscriber = new AtomicReference>(); @@ -263,7 +263,7 @@ void drain() { Publisher otherSource; try { - otherSource = ObjectHelper.requireNonNull(other.call(), "The other Callable returned a null Publisher"); + otherSource = ObjectHelper.requireNonNull(other.get(), "The other Supplier returned a null Publisher"); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); errors.addThrowable(ex); diff --git a/src/main/java/io/reactivex/internal/operators/flowable/FlowableWithLatestFromMany.java b/src/main/java/io/reactivex/internal/operators/flowable/FlowableWithLatestFromMany.java index 6d6b949c33..d42d9693e9 100644 --- a/src/main/java/io/reactivex/internal/operators/flowable/FlowableWithLatestFromMany.java +++ b/src/main/java/io/reactivex/internal/operators/flowable/FlowableWithLatestFromMany.java @@ -296,7 +296,7 @@ void dispose() { final class SingletonArrayFunc implements Function { @Override - public R apply(T t) throws Exception { + public R apply(T t) throws Throwable { return ObjectHelper.requireNonNull(combiner.apply(new Object[] { t }), "The combiner returned a null value"); } } diff --git a/src/main/java/io/reactivex/internal/operators/maybe/MaybeDefer.java b/src/main/java/io/reactivex/internal/operators/maybe/MaybeDefer.java index 63c6f7c61f..f48b274d10 100644 --- a/src/main/java/io/reactivex/internal/operators/maybe/MaybeDefer.java +++ b/src/main/java/io/reactivex/internal/operators/maybe/MaybeDefer.java @@ -13,10 +13,9 @@ package io.reactivex.internal.operators.maybe; -import java.util.concurrent.Callable; - import io.reactivex.*; import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.Supplier; import io.reactivex.internal.disposables.EmptyDisposable; import io.reactivex.internal.functions.ObjectHelper; @@ -27,9 +26,9 @@ */ public final class MaybeDefer extends Maybe { - final Callable> maybeSupplier; + final Supplier> maybeSupplier; - public MaybeDefer(Callable> maybeSupplier) { + public MaybeDefer(Supplier> maybeSupplier) { this.maybeSupplier = maybeSupplier; } @@ -38,7 +37,7 @@ protected void subscribeActual(MaybeObserver observer) { MaybeSource source; try { - source = ObjectHelper.requireNonNull(maybeSupplier.call(), "The maybeSupplier returned a null MaybeSource"); + source = ObjectHelper.requireNonNull(maybeSupplier.get(), "The maybeSupplier returned a null MaybeSource"); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); EmptyDisposable.error(ex, observer); diff --git a/src/main/java/io/reactivex/internal/operators/maybe/MaybeEmpty.java b/src/main/java/io/reactivex/internal/operators/maybe/MaybeEmpty.java index 45514b4232..150770cb01 100644 --- a/src/main/java/io/reactivex/internal/operators/maybe/MaybeEmpty.java +++ b/src/main/java/io/reactivex/internal/operators/maybe/MaybeEmpty.java @@ -15,12 +15,12 @@ import io.reactivex.*; import io.reactivex.internal.disposables.EmptyDisposable; -import io.reactivex.internal.fuseable.ScalarCallable; +import io.reactivex.internal.fuseable.ScalarSupplier; /** * Signals an onComplete. */ -public final class MaybeEmpty extends Maybe implements ScalarCallable { +public final class MaybeEmpty extends Maybe implements ScalarSupplier { public static final MaybeEmpty INSTANCE = new MaybeEmpty(); @@ -30,7 +30,7 @@ protected void subscribeActual(MaybeObserver observer) { } @Override - public Object call() { + public Object get() { return null; // nulls of ScalarCallable are considered empty sources } } diff --git a/src/main/java/io/reactivex/internal/operators/maybe/MaybeErrorCallable.java b/src/main/java/io/reactivex/internal/operators/maybe/MaybeErrorCallable.java index 2378d29890..b480a01478 100644 --- a/src/main/java/io/reactivex/internal/operators/maybe/MaybeErrorCallable.java +++ b/src/main/java/io/reactivex/internal/operators/maybe/MaybeErrorCallable.java @@ -13,23 +13,22 @@ package io.reactivex.internal.operators.maybe; -import io.reactivex.internal.functions.ObjectHelper; -import java.util.concurrent.Callable; - import io.reactivex.*; import io.reactivex.disposables.Disposables; import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.Supplier; +import io.reactivex.internal.functions.ObjectHelper; /** - * Signals a Throwable returned by a Callable. + * Signals a Throwable returned by a Supplier. * * @param the value type */ public final class MaybeErrorCallable extends Maybe { - final Callable errorSupplier; + final Supplier errorSupplier; - public MaybeErrorCallable(Callable errorSupplier) { + public MaybeErrorCallable(Supplier errorSupplier) { this.errorSupplier = errorSupplier; } @@ -39,7 +38,7 @@ protected void subscribeActual(MaybeObserver observer) { Throwable ex; try { - ex = ObjectHelper.requireNonNull(errorSupplier.call(), "Callable returned null throwable. Null values are generally not allowed in 2.x operators and sources."); + ex = ObjectHelper.requireNonNull(errorSupplier.get(), "Supplier returned null throwable. Null values are generally not allowed in 2.x operators and sources."); } catch (Throwable ex1) { Exceptions.throwIfFatal(ex1); ex = ex1; diff --git a/src/main/java/io/reactivex/internal/operators/maybe/MaybeFlatMapNotification.java b/src/main/java/io/reactivex/internal/operators/maybe/MaybeFlatMapNotification.java index 81eb167484..fa1c6cd3fc 100644 --- a/src/main/java/io/reactivex/internal/operators/maybe/MaybeFlatMapNotification.java +++ b/src/main/java/io/reactivex/internal/operators/maybe/MaybeFlatMapNotification.java @@ -13,13 +13,12 @@ package io.reactivex.internal.operators.maybe; -import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicReference; import io.reactivex.*; import io.reactivex.disposables.Disposable; import io.reactivex.exceptions.*; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; import io.reactivex.internal.disposables.DisposableHelper; import io.reactivex.internal.functions.ObjectHelper; @@ -35,12 +34,12 @@ public final class MaybeFlatMapNotification extends AbstractMaybeWithUpstr final Function> onErrorMapper; - final Callable> onCompleteSupplier; + final Supplier> onCompleteSupplier; public MaybeFlatMapNotification(MaybeSource source, Function> onSuccessMapper, Function> onErrorMapper, - Callable> onCompleteSupplier) { + Supplier> onCompleteSupplier) { super(source); this.onSuccessMapper = onSuccessMapper; this.onErrorMapper = onErrorMapper; @@ -64,14 +63,14 @@ static final class FlatMapMaybeObserver final Function> onErrorMapper; - final Callable> onCompleteSupplier; + final Supplier> onCompleteSupplier; Disposable upstream; FlatMapMaybeObserver(MaybeObserver actual, Function> onSuccessMapper, Function> onErrorMapper, - Callable> onCompleteSupplier) { + Supplier> onCompleteSupplier) { this.downstream = actual; this.onSuccessMapper = onSuccessMapper; this.onErrorMapper = onErrorMapper; @@ -104,7 +103,7 @@ public void onSuccess(T value) { try { source = ObjectHelper.requireNonNull(onSuccessMapper.apply(value), "The onSuccessMapper returned a null MaybeSource"); - } catch (Exception ex) { + } catch (Throwable ex) { Exceptions.throwIfFatal(ex); downstream.onError(ex); return; @@ -119,7 +118,7 @@ public void onError(Throwable e) { try { source = ObjectHelper.requireNonNull(onErrorMapper.apply(e), "The onErrorMapper returned a null MaybeSource"); - } catch (Exception ex) { + } catch (Throwable ex) { Exceptions.throwIfFatal(ex); downstream.onError(new CompositeException(e, ex)); return; @@ -133,8 +132,8 @@ public void onComplete() { MaybeSource source; try { - source = ObjectHelper.requireNonNull(onCompleteSupplier.call(), "The onCompleteSupplier returned a null MaybeSource"); - } catch (Exception ex) { + source = ObjectHelper.requireNonNull(onCompleteSupplier.get(), "The onCompleteSupplier returned a null MaybeSource"); + } catch (Throwable ex) { Exceptions.throwIfFatal(ex); downstream.onError(ex); return; diff --git a/src/main/java/io/reactivex/internal/operators/maybe/MaybeFlatten.java b/src/main/java/io/reactivex/internal/operators/maybe/MaybeFlatten.java index 6463ef270b..3df8b986ad 100644 --- a/src/main/java/io/reactivex/internal/operators/maybe/MaybeFlatten.java +++ b/src/main/java/io/reactivex/internal/operators/maybe/MaybeFlatten.java @@ -86,7 +86,7 @@ public void onSuccess(T value) { try { source = ObjectHelper.requireNonNull(mapper.apply(value), "The mapper returned a null MaybeSource"); - } catch (Exception ex) { + } catch (Throwable ex) { Exceptions.throwIfFatal(ex); downstream.onError(ex); return; diff --git a/src/main/java/io/reactivex/internal/operators/maybe/MaybeFromAction.java b/src/main/java/io/reactivex/internal/operators/maybe/MaybeFromAction.java index a4acb44b70..ec9ddd11fa 100644 --- a/src/main/java/io/reactivex/internal/operators/maybe/MaybeFromAction.java +++ b/src/main/java/io/reactivex/internal/operators/maybe/MaybeFromAction.java @@ -13,12 +13,10 @@ package io.reactivex.internal.operators.maybe; -import java.util.concurrent.Callable; - import io.reactivex.*; import io.reactivex.disposables.*; import io.reactivex.exceptions.Exceptions; -import io.reactivex.functions.Action; +import io.reactivex.functions.*; import io.reactivex.plugins.RxJavaPlugins; /** @@ -26,7 +24,7 @@ * * @param the value type */ -public final class MaybeFromAction extends Maybe implements Callable { +public final class MaybeFromAction extends Maybe implements Supplier { final Action action; @@ -60,7 +58,7 @@ protected void subscribeActual(MaybeObserver observer) { } @Override - public T call() throws Exception { + public T get() throws Throwable { action.run(); return null; // considered as onComplete() } diff --git a/src/main/java/io/reactivex/internal/operators/maybe/MaybeFromCallable.java b/src/main/java/io/reactivex/internal/operators/maybe/MaybeFromCallable.java index 6ac93338f6..c8f81e3fed 100644 --- a/src/main/java/io/reactivex/internal/operators/maybe/MaybeFromCallable.java +++ b/src/main/java/io/reactivex/internal/operators/maybe/MaybeFromCallable.java @@ -18,6 +18,7 @@ import io.reactivex.*; import io.reactivex.disposables.*; import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.Supplier; import io.reactivex.plugins.RxJavaPlugins; /** @@ -25,7 +26,7 @@ * * @param the value type */ -public final class MaybeFromCallable extends Maybe implements Callable { +public final class MaybeFromCallable extends Maybe implements Supplier { final Callable callable; @@ -65,7 +66,7 @@ protected void subscribeActual(MaybeObserver observer) { } @Override - public T call() throws Exception { + public T get() throws Exception { return callable.call(); } } diff --git a/src/main/java/io/reactivex/internal/operators/maybe/MaybeFromRunnable.java b/src/main/java/io/reactivex/internal/operators/maybe/MaybeFromRunnable.java index 1514fab204..d38e8f497f 100644 --- a/src/main/java/io/reactivex/internal/operators/maybe/MaybeFromRunnable.java +++ b/src/main/java/io/reactivex/internal/operators/maybe/MaybeFromRunnable.java @@ -13,11 +13,10 @@ package io.reactivex.internal.operators.maybe; -import java.util.concurrent.Callable; - import io.reactivex.*; import io.reactivex.disposables.*; import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.Supplier; import io.reactivex.plugins.RxJavaPlugins; /** @@ -25,7 +24,7 @@ * * @param the value type */ -public final class MaybeFromRunnable extends Maybe implements Callable { +public final class MaybeFromRunnable extends Maybe implements Supplier { final Runnable runnable; @@ -59,7 +58,7 @@ protected void subscribeActual(MaybeObserver observer) { } @Override - public T call() throws Exception { + public T get() throws Throwable { runnable.run(); return null; } diff --git a/src/main/java/io/reactivex/internal/operators/maybe/MaybeJust.java b/src/main/java/io/reactivex/internal/operators/maybe/MaybeJust.java index 4b2047b360..d93c8277db 100644 --- a/src/main/java/io/reactivex/internal/operators/maybe/MaybeJust.java +++ b/src/main/java/io/reactivex/internal/operators/maybe/MaybeJust.java @@ -15,14 +15,14 @@ import io.reactivex.*; import io.reactivex.disposables.Disposables; -import io.reactivex.internal.fuseable.ScalarCallable; +import io.reactivex.internal.fuseable.ScalarSupplier; /** * Signals a constant value. * * @param the value type */ -public final class MaybeJust extends Maybe implements ScalarCallable { +public final class MaybeJust extends Maybe implements ScalarSupplier { final T value; @@ -37,7 +37,7 @@ protected void subscribeActual(MaybeObserver observer) { } @Override - public T call() { + public T get() { return value; } } diff --git a/src/main/java/io/reactivex/internal/operators/maybe/MaybeUsing.java b/src/main/java/io/reactivex/internal/operators/maybe/MaybeUsing.java index 4628d1261c..5021eb9996 100644 --- a/src/main/java/io/reactivex/internal/operators/maybe/MaybeUsing.java +++ b/src/main/java/io/reactivex/internal/operators/maybe/MaybeUsing.java @@ -13,7 +13,6 @@ package io.reactivex.internal.operators.maybe; -import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicReference; import io.reactivex.*; @@ -33,7 +32,7 @@ */ public final class MaybeUsing extends Maybe { - final Callable resourceSupplier; + final Supplier resourceSupplier; final Function> sourceSupplier; @@ -41,7 +40,7 @@ public final class MaybeUsing extends Maybe { final boolean eager; - public MaybeUsing(Callable resourceSupplier, + public MaybeUsing(Supplier resourceSupplier, Function> sourceSupplier, Consumer resourceDisposer, boolean eager) { @@ -56,7 +55,7 @@ protected void subscribeActual(MaybeObserver observer) { D resource; try { - resource = resourceSupplier.call(); + resource = resourceSupplier.get(); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); EmptyDisposable.error(ex, observer); diff --git a/src/main/java/io/reactivex/internal/operators/maybe/MaybeZipArray.java b/src/main/java/io/reactivex/internal/operators/maybe/MaybeZipArray.java index d9cc0028af..ce8ed0048a 100644 --- a/src/main/java/io/reactivex/internal/operators/maybe/MaybeZipArray.java +++ b/src/main/java/io/reactivex/internal/operators/maybe/MaybeZipArray.java @@ -189,7 +189,7 @@ public void onComplete() { final class SingletonArrayFunc implements Function { @Override - public R apply(T t) throws Exception { + public R apply(T t) throws Throwable { return ObjectHelper.requireNonNull(zipper.apply(new Object[] { t }), "The zipper returned a null value"); } } diff --git a/src/main/java/io/reactivex/internal/operators/maybe/MaybeZipIterable.java b/src/main/java/io/reactivex/internal/operators/maybe/MaybeZipIterable.java index 7815bab095..244e42a36e 100644 --- a/src/main/java/io/reactivex/internal/operators/maybe/MaybeZipIterable.java +++ b/src/main/java/io/reactivex/internal/operators/maybe/MaybeZipIterable.java @@ -81,7 +81,7 @@ protected void subscribeActual(MaybeObserver observer) { final class SingletonArrayFunc implements Function { @Override - public R apply(T t) throws Exception { + public R apply(T t) throws Throwable { return ObjectHelper.requireNonNull(zipper.apply(new Object[] { t }), "The zipper returned a null value"); } } diff --git a/src/main/java/io/reactivex/internal/operators/mixed/ScalarXMapZHelper.java b/src/main/java/io/reactivex/internal/operators/mixed/ScalarXMapZHelper.java index 2755a42c9d..d8ae77f8df 100644 --- a/src/main/java/io/reactivex/internal/operators/mixed/ScalarXMapZHelper.java +++ b/src/main/java/io/reactivex/internal/operators/mixed/ScalarXMapZHelper.java @@ -13,11 +13,9 @@ package io.reactivex.internal.operators.mixed; -import java.util.concurrent.Callable; - import io.reactivex.*; import io.reactivex.exceptions.Exceptions; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; import io.reactivex.internal.disposables.EmptyDisposable; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.operators.maybe.MaybeToObservable; @@ -38,10 +36,10 @@ private ScalarXMapZHelper() { /** * Try subscribing to a {@link CompletableSource} mapped from - * a scalar source (which implements {@link Callable}). + * a scalar source (which implements {@link Supplier}). * @param the upstream value type * @param source the source reactive type ({@code Flowable} or {@code Observable}) - * possibly implementing {@link Callable}. + * possibly implementing {@link Supplier}. * @param mapper the function that turns the scalar upstream value into a * {@link CompletableSource} * @param observer the consumer to subscribe to the mapped {@link CompletableSource} @@ -50,12 +48,12 @@ private ScalarXMapZHelper() { static boolean tryAsCompletable(Object source, Function mapper, CompletableObserver observer) { - if (source instanceof Callable) { + if (source instanceof Supplier) { @SuppressWarnings("unchecked") - Callable call = (Callable) source; + Supplier supplier = (Supplier) source; CompletableSource cs = null; try { - T item = call.call(); + T item = supplier.get(); if (item != null) { cs = ObjectHelper.requireNonNull(mapper.apply(item), "The mapper returned a null CompletableSource"); } @@ -77,10 +75,10 @@ static boolean tryAsCompletable(Object source, /** * Try subscribing to a {@link MaybeSource} mapped from - * a scalar source (which implements {@link Callable}). + * a scalar source (which implements {@link Supplier}). * @param the upstream value type * @param source the source reactive type ({@code Flowable} or {@code Observable}) - * possibly implementing {@link Callable}. + * possibly implementing {@link Supplier}. * @param mapper the function that turns the scalar upstream value into a * {@link MaybeSource} * @param observer the consumer to subscribe to the mapped {@link MaybeSource} @@ -89,12 +87,12 @@ static boolean tryAsCompletable(Object source, static boolean tryAsMaybe(Object source, Function> mapper, Observer observer) { - if (source instanceof Callable) { + if (source instanceof Supplier) { @SuppressWarnings("unchecked") - Callable call = (Callable) source; + Supplier supplier = (Supplier) source; MaybeSource cs = null; try { - T item = call.call(); + T item = supplier.get(); if (item != null) { cs = ObjectHelper.requireNonNull(mapper.apply(item), "The mapper returned a null MaybeSource"); } @@ -116,10 +114,10 @@ static boolean tryAsMaybe(Object source, /** * Try subscribing to a {@link SingleSource} mapped from - * a scalar source (which implements {@link Callable}). + * a scalar source (which implements {@link Supplier}). * @param the upstream value type * @param source the source reactive type ({@code Flowable} or {@code Observable}) - * possibly implementing {@link Callable}. + * possibly implementing {@link Supplier}. * @param mapper the function that turns the scalar upstream value into a * {@link SingleSource} * @param observer the consumer to subscribe to the mapped {@link SingleSource} @@ -128,12 +126,12 @@ static boolean tryAsMaybe(Object source, static boolean tryAsSingle(Object source, Function> mapper, Observer observer) { - if (source instanceof Callable) { + if (source instanceof Supplier) { @SuppressWarnings("unchecked") - Callable call = (Callable) source; + Supplier supplier = (Supplier) source; SingleSource cs = null; try { - T item = call.call(); + T item = supplier.get(); if (item != null) { cs = ObjectHelper.requireNonNull(mapper.apply(item), "The mapper returned a null SingleSource"); } diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableBuffer.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableBuffer.java index 369eb4260d..701d8006ab 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableBuffer.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableBuffer.java @@ -13,23 +13,23 @@ package io.reactivex.internal.operators.observable; -import io.reactivex.internal.functions.ObjectHelper; import java.util.*; -import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicBoolean; import io.reactivex.ObservableSource; import io.reactivex.Observer; import io.reactivex.disposables.Disposable; import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.Supplier; import io.reactivex.internal.disposables.*; +import io.reactivex.internal.functions.ObjectHelper; public final class ObservableBuffer> extends AbstractObservableWithUpstream { final int count; final int skip; - final Callable bufferSupplier; + final Supplier bufferSupplier; - public ObservableBuffer(ObservableSource source, int count, int skip, Callable bufferSupplier) { + public ObservableBuffer(ObservableSource source, int count, int skip, Supplier bufferSupplier) { super(source); this.count = count; this.skip = skip; @@ -51,14 +51,14 @@ protected void subscribeActual(Observer t) { static final class BufferExactObserver> implements Observer, Disposable { final Observer downstream; final int count; - final Callable bufferSupplier; + final Supplier bufferSupplier; U buffer; int size; Disposable upstream; - BufferExactObserver(Observer actual, int count, Callable bufferSupplier) { + BufferExactObserver(Observer actual, int count, Supplier bufferSupplier) { this.downstream = actual; this.count = count; this.bufferSupplier = bufferSupplier; @@ -67,7 +67,7 @@ static final class BufferExactObserver> imple boolean createBuffer() { U b; try { - b = ObjectHelper.requireNonNull(bufferSupplier.call(), "Empty buffer supplied"); + b = ObjectHelper.requireNonNull(bufferSupplier.get(), "Empty buffer supplied"); } catch (Throwable t) { Exceptions.throwIfFatal(t); buffer = null; @@ -144,7 +144,7 @@ static final class BufferSkipObserver> final Observer downstream; final int count; final int skip; - final Callable bufferSupplier; + final Supplier bufferSupplier; Disposable upstream; @@ -152,7 +152,7 @@ static final class BufferSkipObserver> long index; - BufferSkipObserver(Observer actual, int count, int skip, Callable bufferSupplier) { + BufferSkipObserver(Observer actual, int count, int skip, Supplier bufferSupplier) { this.downstream = actual; this.count = count; this.skip = skip; @@ -184,7 +184,7 @@ public void onNext(T t) { U b; try { - b = ObjectHelper.requireNonNull(bufferSupplier.call(), "The bufferSupplier returned a null collection. Null values are generally not allowed in 2.x operators and sources."); + b = ObjectHelper.requireNonNull(bufferSupplier.get(), "The bufferSupplier returned a null collection. Null values are generally not allowed in 2.x operators and sources."); } catch (Throwable e) { buffers.clear(); upstream.dispose(); diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableBufferBoundary.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableBufferBoundary.java index 09f5b2d3d7..466c15127f 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableBufferBoundary.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableBufferBoundary.java @@ -14,14 +14,13 @@ package io.reactivex.internal.operators.observable; import java.util.*; -import java.util.concurrent.Callable; import java.util.concurrent.atomic.*; import io.reactivex.ObservableSource; import io.reactivex.Observer; import io.reactivex.disposables.*; import io.reactivex.exceptions.Exceptions; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; import io.reactivex.internal.disposables.DisposableHelper; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.queue.SpscLinkedArrayQueue; @@ -30,12 +29,12 @@ public final class ObservableBufferBoundary, Open, Close> extends AbstractObservableWithUpstream { - final Callable bufferSupplier; + final Supplier bufferSupplier; final ObservableSource bufferOpen; final Function> bufferClose; public ObservableBufferBoundary(ObservableSource source, ObservableSource bufferOpen, - Function> bufferClose, Callable bufferSupplier) { + Function> bufferClose, Supplier bufferSupplier) { super(source); this.bufferOpen = bufferOpen; this.bufferClose = bufferClose; @@ -59,7 +58,7 @@ static final class BufferBoundaryObserver, Op final Observer downstream; - final Callable bufferSupplier; + final Supplier bufferSupplier; final ObservableSource bufferOpen; @@ -84,7 +83,7 @@ static final class BufferBoundaryObserver, Op BufferBoundaryObserver(Observer actual, ObservableSource bufferOpen, Function> bufferClose, - Callable bufferSupplier + Supplier bufferSupplier ) { this.downstream = actual; this.bufferSupplier = bufferSupplier; @@ -175,7 +174,7 @@ void open(Open token) { ObservableSource p; C buf; try { - buf = ObjectHelper.requireNonNull(bufferSupplier.call(), "The bufferSupplier returned a null Collection"); + buf = ObjectHelper.requireNonNull(bufferSupplier.get(), "The bufferSupplier returned a null Collection"); p = ObjectHelper.requireNonNull(bufferClose.apply(token), "The bufferClose returned a null ObservableSource"); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableBufferBoundarySupplier.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableBufferBoundarySupplier.java index b642bf1c9c..dca3ddbb1a 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableBufferBoundarySupplier.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableBufferBoundarySupplier.java @@ -13,15 +13,15 @@ package io.reactivex.internal.operators.observable; -import io.reactivex.internal.functions.ObjectHelper; import java.util.Collection; -import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicReference; import io.reactivex.*; import io.reactivex.disposables.Disposable; import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.Supplier; import io.reactivex.internal.disposables.*; +import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.observers.QueueDrainObserver; import io.reactivex.internal.queue.MpscLinkedQueue; import io.reactivex.internal.util.QueueDrainHelper; @@ -30,10 +30,10 @@ public final class ObservableBufferBoundarySupplier, B> extends AbstractObservableWithUpstream { - final Callable> boundarySupplier; - final Callable bufferSupplier; + final Supplier> boundarySupplier; + final Supplier bufferSupplier; - public ObservableBufferBoundarySupplier(ObservableSource source, Callable> boundarySupplier, Callable bufferSupplier) { + public ObservableBufferBoundarySupplier(ObservableSource source, Supplier> boundarySupplier, Supplier bufferSupplier) { super(source); this.boundarySupplier = boundarySupplier; this.bufferSupplier = bufferSupplier; @@ -47,8 +47,8 @@ protected void subscribeActual(Observer t) { static final class BufferBoundarySupplierObserver, B> extends QueueDrainObserver implements Observer, Disposable { - final Callable bufferSupplier; - final Callable> boundarySupplier; + final Supplier bufferSupplier; + final Supplier> boundarySupplier; Disposable upstream; @@ -56,8 +56,8 @@ static final class BufferBoundarySupplierObserver actual, Callable bufferSupplier, - Callable> boundarySupplier) { + BufferBoundarySupplierObserver(Observer actual, Supplier bufferSupplier, + Supplier> boundarySupplier) { super(actual, new MpscLinkedQueue()); this.bufferSupplier = bufferSupplier; this.boundarySupplier = boundarySupplier; @@ -73,7 +73,7 @@ public void onSubscribe(Disposable d) { U b; try { - b = ObjectHelper.requireNonNull(bufferSupplier.call(), "The buffer supplied is null"); + b = ObjectHelper.requireNonNull(bufferSupplier.get(), "The buffer supplied is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); cancelled = true; @@ -87,7 +87,7 @@ public void onSubscribe(Disposable d) { ObservableSource boundary; try { - boundary = ObjectHelper.requireNonNull(boundarySupplier.call(), "The boundary ObservableSource supplied is null"); + boundary = ObjectHelper.requireNonNull(boundarySupplier.get(), "The boundary ObservableSource supplied is null"); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); cancelled = true; @@ -168,7 +168,7 @@ void next() { U next; try { - next = ObjectHelper.requireNonNull(bufferSupplier.call(), "The buffer supplied is null"); + next = ObjectHelper.requireNonNull(bufferSupplier.get(), "The buffer supplied is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); dispose(); @@ -179,7 +179,7 @@ void next() { ObservableSource boundary; try { - boundary = ObjectHelper.requireNonNull(boundarySupplier.call(), "The boundary ObservableSource supplied is null"); + boundary = ObjectHelper.requireNonNull(boundarySupplier.get(), "The boundary ObservableSource supplied is null"); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); cancelled = true; diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableBufferExactBoundary.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableBufferExactBoundary.java index b80d303be2..0a970c0c40 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableBufferExactBoundary.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableBufferExactBoundary.java @@ -13,14 +13,14 @@ package io.reactivex.internal.operators.observable; -import io.reactivex.internal.functions.ObjectHelper; import java.util.Collection; -import java.util.concurrent.Callable; import io.reactivex.*; import io.reactivex.disposables.Disposable; import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.Supplier; import io.reactivex.internal.disposables.*; +import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.observers.QueueDrainObserver; import io.reactivex.internal.queue.MpscLinkedQueue; import io.reactivex.internal.util.QueueDrainHelper; @@ -29,9 +29,9 @@ public final class ObservableBufferExactBoundary, B> extends AbstractObservableWithUpstream { final ObservableSource boundary; - final Callable bufferSupplier; + final Supplier bufferSupplier; - public ObservableBufferExactBoundary(ObservableSource source, ObservableSource boundary, Callable bufferSupplier) { + public ObservableBufferExactBoundary(ObservableSource source, ObservableSource boundary, Supplier bufferSupplier) { super(source); this.boundary = boundary; this.bufferSupplier = bufferSupplier; @@ -45,7 +45,7 @@ protected void subscribeActual(Observer t) { static final class BufferExactBoundaryObserver, B> extends QueueDrainObserver implements Observer, Disposable { - final Callable bufferSupplier; + final Supplier bufferSupplier; final ObservableSource boundary; Disposable upstream; @@ -54,7 +54,7 @@ static final class BufferExactBoundaryObserver actual, Callable bufferSupplier, + BufferExactBoundaryObserver(Observer actual, Supplier bufferSupplier, ObservableSource boundary) { super(actual, new MpscLinkedQueue()); this.bufferSupplier = bufferSupplier; @@ -69,7 +69,7 @@ public void onSubscribe(Disposable d) { U b; try { - b = ObjectHelper.requireNonNull(bufferSupplier.call(), "The buffer supplied is null"); + b = ObjectHelper.requireNonNull(bufferSupplier.get(), "The buffer supplied is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); cancelled = true; @@ -148,7 +148,7 @@ void next() { U next; try { - next = ObjectHelper.requireNonNull(bufferSupplier.call(), "The buffer supplied is null"); + next = ObjectHelper.requireNonNull(bufferSupplier.get(), "The buffer supplied is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); dispose(); diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableBufferTimed.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableBufferTimed.java index b9f692db9d..d777938146 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableBufferTimed.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableBufferTimed.java @@ -22,6 +22,7 @@ import io.reactivex.Scheduler.Worker; import io.reactivex.disposables.Disposable; import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.Supplier; import io.reactivex.internal.disposables.*; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.observers.QueueDrainObserver; @@ -36,11 +37,11 @@ public final class ObservableBufferTimed> final long timeskip; final TimeUnit unit; final Scheduler scheduler; - final Callable bufferSupplier; + final Supplier bufferSupplier; final int maxSize; final boolean restartTimerOnMaxSize; - public ObservableBufferTimed(ObservableSource source, long timespan, long timeskip, TimeUnit unit, Scheduler scheduler, Callable bufferSupplier, int maxSize, + public ObservableBufferTimed(ObservableSource source, long timespan, long timeskip, TimeUnit unit, Scheduler scheduler, Supplier bufferSupplier, int maxSize, boolean restartTimerOnMaxSize) { super(source); this.timespan = timespan; @@ -80,7 +81,7 @@ protected void subscribeActual(Observer t) { static final class BufferExactUnboundedObserver> extends QueueDrainObserver implements Runnable, Disposable { - final Callable bufferSupplier; + final Supplier bufferSupplier; final long timespan; final TimeUnit unit; final Scheduler scheduler; @@ -92,7 +93,7 @@ static final class BufferExactUnboundedObserver timer = new AtomicReference(); BufferExactUnboundedObserver( - Observer actual, Callable bufferSupplier, + Observer actual, Supplier bufferSupplier, long timespan, TimeUnit unit, Scheduler scheduler) { super(actual, new MpscLinkedQueue()); this.bufferSupplier = bufferSupplier; @@ -109,7 +110,7 @@ public void onSubscribe(Disposable d) { U b; try { - b = ObjectHelper.requireNonNull(bufferSupplier.call(), "The buffer supplied is null"); + b = ObjectHelper.requireNonNull(bufferSupplier.get(), "The buffer supplied is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); dispose(); @@ -183,7 +184,7 @@ public void run() { U next; try { - next = ObjectHelper.requireNonNull(bufferSupplier.call(), "The bufferSupplier returned a null buffer"); + next = ObjectHelper.requireNonNull(bufferSupplier.get(), "The bufferSupplier returned a null buffer"); } catch (Throwable e) { Exceptions.throwIfFatal(e); downstream.onError(e); @@ -216,7 +217,7 @@ public void accept(Observer a, U v) { static final class BufferSkipBoundedObserver> extends QueueDrainObserver implements Runnable, Disposable { - final Callable bufferSupplier; + final Supplier bufferSupplier; final long timespan; final long timeskip; final TimeUnit unit; @@ -226,7 +227,7 @@ static final class BufferSkipBoundedObserver> Disposable upstream; BufferSkipBoundedObserver(Observer actual, - Callable bufferSupplier, long timespan, + Supplier bufferSupplier, long timespan, long timeskip, TimeUnit unit, Worker w) { super(actual, new MpscLinkedQueue()); this.bufferSupplier = bufferSupplier; @@ -245,7 +246,7 @@ public void onSubscribe(Disposable d) { final U b; // NOPMD try { - b = ObjectHelper.requireNonNull(bufferSupplier.call(), "The buffer supplied is null"); + b = ObjectHelper.requireNonNull(bufferSupplier.get(), "The buffer supplied is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); d.dispose(); @@ -327,7 +328,7 @@ public void run() { final U b; // NOPMD try { - b = ObjectHelper.requireNonNull(bufferSupplier.call(), "The bufferSupplier returned a null buffer"); + b = ObjectHelper.requireNonNull(bufferSupplier.get(), "The bufferSupplier returned a null buffer"); } catch (Throwable e) { Exceptions.throwIfFatal(e); downstream.onError(e); @@ -387,7 +388,7 @@ public void run() { static final class BufferExactBoundedObserver> extends QueueDrainObserver implements Runnable, Disposable { - final Callable bufferSupplier; + final Supplier bufferSupplier; final long timespan; final TimeUnit unit; final int maxSize; @@ -406,7 +407,7 @@ static final class BufferExactBoundedObserver BufferExactBoundedObserver( Observer actual, - Callable bufferSupplier, + Supplier bufferSupplier, long timespan, TimeUnit unit, int maxSize, boolean restartOnMaxSize, Worker w) { super(actual, new MpscLinkedQueue()); @@ -426,7 +427,7 @@ public void onSubscribe(Disposable d) { U b; try { - b = ObjectHelper.requireNonNull(bufferSupplier.call(), "The buffer supplied is null"); + b = ObjectHelper.requireNonNull(bufferSupplier.get(), "The buffer supplied is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); d.dispose(); @@ -468,7 +469,7 @@ public void onNext(T t) { fastPathOrderedEmit(b, false, this); try { - b = ObjectHelper.requireNonNull(bufferSupplier.call(), "The buffer supplied is null"); + b = ObjectHelper.requireNonNull(bufferSupplier.get(), "The buffer supplied is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); downstream.onError(e); @@ -540,7 +541,7 @@ public void run() { U next; try { - next = ObjectHelper.requireNonNull(bufferSupplier.call(), "The bufferSupplier returned a null buffer"); + next = ObjectHelper.requireNonNull(bufferSupplier.get(), "The bufferSupplier returned a null buffer"); } catch (Throwable e) { Exceptions.throwIfFatal(e); dispose(); diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableCollect.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableCollect.java index 761fabd49e..c0e9444d50 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableCollect.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableCollect.java @@ -12,21 +12,19 @@ */ package io.reactivex.internal.operators.observable; -import io.reactivex.internal.functions.ObjectHelper; -import java.util.concurrent.Callable; - import io.reactivex.*; import io.reactivex.disposables.Disposable; -import io.reactivex.functions.BiConsumer; +import io.reactivex.functions.*; import io.reactivex.internal.disposables.*; +import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.plugins.RxJavaPlugins; public final class ObservableCollect extends AbstractObservableWithUpstream { - final Callable initialSupplier; + final Supplier initialSupplier; final BiConsumer collector; public ObservableCollect(ObservableSource source, - Callable initialSupplier, BiConsumer collector) { + Supplier initialSupplier, BiConsumer collector) { super(source); this.initialSupplier = initialSupplier; this.collector = collector; @@ -36,7 +34,7 @@ public ObservableCollect(ObservableSource source, protected void subscribeActual(Observer t) { U u; try { - u = ObjectHelper.requireNonNull(initialSupplier.call(), "The initialSupplier returned a null value"); + u = ObjectHelper.requireNonNull(initialSupplier.get(), "The initialSupplier returned a null value"); } catch (Throwable e) { EmptyDisposable.error(e, t); return; diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableCollectSingle.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableCollectSingle.java index 59c34a0048..e08dae6352 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableCollectSingle.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableCollectSingle.java @@ -12,11 +12,9 @@ */ package io.reactivex.internal.operators.observable; -import java.util.concurrent.Callable; - import io.reactivex.*; import io.reactivex.disposables.Disposable; -import io.reactivex.functions.BiConsumer; +import io.reactivex.functions.*; import io.reactivex.internal.disposables.*; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.fuseable.FuseToObservable; @@ -26,11 +24,11 @@ public final class ObservableCollectSingle extends Single implements Fu final ObservableSource source; - final Callable initialSupplier; + final Supplier initialSupplier; final BiConsumer collector; public ObservableCollectSingle(ObservableSource source, - Callable initialSupplier, BiConsumer collector) { + Supplier initialSupplier, BiConsumer collector) { this.source = source; this.initialSupplier = initialSupplier; this.collector = collector; @@ -40,7 +38,7 @@ public ObservableCollectSingle(ObservableSource source, protected void subscribeActual(SingleObserver t) { U u; try { - u = ObjectHelper.requireNonNull(initialSupplier.call(), "The initialSupplier returned a null value"); + u = ObjectHelper.requireNonNull(initialSupplier.get(), "The initialSupplier returned a null value"); } catch (Throwable e) { EmptyDisposable.error(e, t); return; diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableConcatMap.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableConcatMap.java index a59841d501..ce8d23acfd 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableConcatMap.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableConcatMap.java @@ -12,14 +12,13 @@ */ package io.reactivex.internal.operators.observable; -import java.util.concurrent.Callable; import java.util.concurrent.atomic.*; import io.reactivex.*; import io.reactivex.disposables.Disposable; import io.reactivex.exceptions.Exceptions; -import io.reactivex.functions.Function; -import io.reactivex.internal.disposables.*; +import io.reactivex.functions.*; +import io.reactivex.internal.disposables.DisposableHelper; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.fuseable.*; import io.reactivex.internal.queue.SpscLinkedArrayQueue; @@ -455,11 +454,11 @@ void drain() { return; } - if (o instanceof Callable) { + if (o instanceof Supplier) { R w; try { - w = ((Callable)o).call(); + w = ((Supplier)o).get(); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); error.addThrowable(ex); diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableDefer.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableDefer.java index adc2c29008..b0b6e9052e 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableDefer.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableDefer.java @@ -13,16 +13,15 @@ package io.reactivex.internal.operators.observable; -import io.reactivex.internal.functions.ObjectHelper; -import java.util.concurrent.Callable; - import io.reactivex.*; import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.Supplier; import io.reactivex.internal.disposables.EmptyDisposable; +import io.reactivex.internal.functions.ObjectHelper; public final class ObservableDefer extends Observable { - final Callable> supplier; - public ObservableDefer(Callable> supplier) { + final Supplier> supplier; + public ObservableDefer(Supplier> supplier) { this.supplier = supplier; } @@ -30,7 +29,7 @@ public ObservableDefer(Callable> supplie public void subscribeActual(Observer observer) { ObservableSource pub; try { - pub = ObjectHelper.requireNonNull(supplier.call(), "null ObservableSource supplied"); + pub = ObjectHelper.requireNonNull(supplier.get(), "The supplier returned a null ObservableSource"); } catch (Throwable t) { Exceptions.throwIfFatal(t); EmptyDisposable.error(t, observer); diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableDistinct.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableDistinct.java index 6ebe127e4e..dcc45fbd88 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableDistinct.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableDistinct.java @@ -14,12 +14,11 @@ package io.reactivex.internal.operators.observable; import java.util.Collection; -import java.util.concurrent.Callable; import io.reactivex.*; import io.reactivex.annotations.Nullable; import io.reactivex.exceptions.Exceptions; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; import io.reactivex.internal.disposables.EmptyDisposable; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.observers.BasicFuseableObserver; @@ -29,9 +28,9 @@ public final class ObservableDistinct extends AbstractObservableWithUpstre final Function keySelector; - final Callable> collectionSupplier; + final Supplier> collectionSupplier; - public ObservableDistinct(ObservableSource source, Function keySelector, Callable> collectionSupplier) { + public ObservableDistinct(ObservableSource source, Function keySelector, Supplier> collectionSupplier) { super(source); this.keySelector = keySelector; this.collectionSupplier = collectionSupplier; @@ -42,7 +41,7 @@ protected void subscribeActual(Observer observer) { Collection collection; try { - collection = ObjectHelper.requireNonNull(collectionSupplier.call(), "The collectionSupplier returned a null collection. Null values are generally not allowed in 2.x operators and sources."); + collection = ObjectHelper.requireNonNull(collectionSupplier.get(), "The collectionSupplier returned a null collection. Null values are generally not allowed in 2.x operators and sources."); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); EmptyDisposable.error(ex, observer); @@ -116,7 +115,7 @@ public int requestFusion(int mode) { @Nullable @Override - public T poll() throws Exception { + public T poll() throws Throwable { for (;;) { T v = qd.poll(); diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableDistinctUntilChanged.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableDistinctUntilChanged.java index 866efd3210..1c322ea1e6 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableDistinctUntilChanged.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableDistinctUntilChanged.java @@ -92,7 +92,7 @@ public int requestFusion(int mode) { @Nullable @Override - public T poll() throws Exception { + public T poll() throws Throwable { for (;;) { T v = qd.poll(); if (v == null) { diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableDoAfterNext.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableDoAfterNext.java index c84f3571ab..34515c92d0 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableDoAfterNext.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableDoAfterNext.java @@ -67,7 +67,7 @@ public int requestFusion(int mode) { @Nullable @Override - public T poll() throws Exception { + public T poll() throws Throwable { T v = qd.poll(); if (v != null) { onAfterNext.accept(v); diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableDoFinally.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableDoFinally.java index bc305afde5..552a9f1edf 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableDoFinally.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableDoFinally.java @@ -128,7 +128,7 @@ public boolean isEmpty() { @Nullable @Override - public T poll() throws Exception { + public T poll() throws Throwable { T v = qd.poll(); if (v == null && syncFused) { runFinally(); diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableEmpty.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableEmpty.java index 0343f13559..149c5bd24d 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableEmpty.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableEmpty.java @@ -15,9 +15,9 @@ import io.reactivex.Observable; import io.reactivex.Observer; import io.reactivex.internal.disposables.EmptyDisposable; -import io.reactivex.internal.fuseable.ScalarCallable; +import io.reactivex.internal.fuseable.ScalarSupplier; -public final class ObservableEmpty extends Observable implements ScalarCallable { +public final class ObservableEmpty extends Observable implements ScalarSupplier { public static final Observable INSTANCE = new ObservableEmpty(); private ObservableEmpty() { @@ -29,7 +29,7 @@ protected void subscribeActual(Observer o) { } @Override - public Object call() { + public Object get() { return null; // null scalar is interpreted as being empty } } diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableError.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableError.java index b0eeb95c56..44e5d8bbfe 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableError.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableError.java @@ -13,16 +13,15 @@ package io.reactivex.internal.operators.observable; -import io.reactivex.internal.functions.ObjectHelper; -import java.util.concurrent.Callable; - import io.reactivex.*; import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.Supplier; import io.reactivex.internal.disposables.EmptyDisposable; +import io.reactivex.internal.functions.ObjectHelper; public final class ObservableError extends Observable { - final Callable errorSupplier; - public ObservableError(Callable errorSupplier) { + final Supplier errorSupplier; + public ObservableError(Supplier errorSupplier) { this.errorSupplier = errorSupplier; } @@ -30,7 +29,7 @@ public ObservableError(Callable errorSupplier) { public void subscribeActual(Observer observer) { Throwable error; try { - error = ObjectHelper.requireNonNull(errorSupplier.call(), "Callable returned null throwable. Null values are generally not allowed in 2.x operators and sources."); + error = ObjectHelper.requireNonNull(errorSupplier.get(), "Supplier returned null throwable. Null values are generally not allowed in 2.x operators and sources."); } catch (Throwable t) { Exceptions.throwIfFatal(t); error = t; diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableFilter.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableFilter.java index c9ec142a76..74dace8416 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableFilter.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableFilter.java @@ -63,7 +63,7 @@ public int requestFusion(int mode) { @Nullable @Override - public T poll() throws Exception { + public T poll() throws Throwable { for (;;) { T v = qd.poll(); if (v == null || filter.test(v)) { diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableFlatMap.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableFlatMap.java index a4766f389d..48cdb8f55e 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableFlatMap.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableFlatMap.java @@ -14,14 +14,13 @@ package io.reactivex.internal.operators.observable; import java.util.*; -import java.util.concurrent.Callable; import java.util.concurrent.atomic.*; import io.reactivex.ObservableSource; import io.reactivex.Observer; import io.reactivex.disposables.Disposable; -import io.reactivex.exceptions.*; -import io.reactivex.functions.Function; +import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.*; import io.reactivex.internal.disposables.DisposableHelper; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.fuseable.*; @@ -142,8 +141,8 @@ public void onNext(T t) { @SuppressWarnings("unchecked") void subscribeInner(ObservableSource p) { for (;;) { - if (p instanceof Callable) { - if (tryEmitScalar(((Callable)p)) && maxConcurrency != Integer.MAX_VALUE) { + if (p instanceof Supplier) { + if (tryEmitScalar(((Supplier)p)) && maxConcurrency != Integer.MAX_VALUE) { boolean empty = false; synchronized (this) { p = sources.poll(); @@ -217,10 +216,10 @@ void removeInner(InnerObserver inner) { } } - boolean tryEmitScalar(Callable value) { + boolean tryEmitScalar(Supplier value) { U u; try { - u = value.call(); + u = value.get(); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); errors.addThrowable(ex); diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableGenerate.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableGenerate.java index 61f4891d1e..39aaff01f0 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableGenerate.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableGenerate.java @@ -13,8 +13,6 @@ package io.reactivex.internal.operators.observable; -import java.util.concurrent.Callable; - import io.reactivex.*; import io.reactivex.disposables.Disposable; import io.reactivex.exceptions.Exceptions; @@ -23,11 +21,11 @@ import io.reactivex.plugins.RxJavaPlugins; public final class ObservableGenerate extends Observable { - final Callable stateSupplier; + final Supplier stateSupplier; final BiFunction, S> generator; final Consumer disposeState; - public ObservableGenerate(Callable stateSupplier, BiFunction, S> generator, + public ObservableGenerate(Supplier stateSupplier, BiFunction, S> generator, Consumer disposeState) { this.stateSupplier = stateSupplier; this.generator = generator; @@ -39,7 +37,7 @@ public void subscribeActual(Observer observer) { S state; try { - state = stateSupplier.call(); + state = stateSupplier.get(); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptyDisposable.error(e, observer); diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableInternalHelper.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableInternalHelper.java index 733b18f0ee..d6d584f361 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableInternalHelper.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableInternalHelper.java @@ -37,7 +37,7 @@ static final class SimpleGenerator implements BiFunction, S> } @Override - public S apply(S t1, Emitter t2) throws Exception { + public S apply(S t1, Emitter t2) throws Throwable { consumer.accept(t2); return t1; } @@ -55,7 +55,7 @@ static final class SimpleBiGenerator implements BiFunction, } @Override - public S apply(S t1, Emitter t2) throws Exception { + public S apply(S t1, Emitter t2) throws Throwable { consumer.accept(t1, t2); return t1; } @@ -73,7 +73,7 @@ static final class ItemDelayFunction implements Function apply(final T v) throws Exception { + public ObservableSource apply(final T v) throws Throwable { ObservableSource o = ObjectHelper.requireNonNull(itemDelay.apply(v), "The itemDelay returned a null ObservableSource"); return new ObservableTake(o, 1).map(Functions.justFunction(v)).defaultIfEmpty(v); } @@ -144,7 +144,7 @@ static final class FlatMapWithCombinerInner implements Function { } @Override - public R apply(U w) throws Exception { + public R apply(U w) throws Throwable { return combiner.apply(t, w); } } @@ -160,7 +160,7 @@ static final class FlatMapWithCombinerOuter implements Function apply(final T t) throws Exception { + public ObservableSource apply(final T t) throws Throwable { @SuppressWarnings("unchecked") ObservableSource u = (ObservableSource)ObjectHelper.requireNonNull(mapper.apply(t), "The mapper returned a null ObservableSource"); return new ObservableMap(u, new FlatMapWithCombinerInner(combiner, t)); @@ -181,7 +181,7 @@ static final class FlatMapIntoIterable implements Function apply(T t) throws Exception { + public ObservableSource apply(T t) throws Throwable { return new ObservableFromIterable(ObjectHelper.requireNonNull(mapper.apply(t), "The mapper returned a null Iterable")); } } @@ -198,19 +198,19 @@ public Object apply(Object t) throws Exception { } } - public static Callable> replayCallable(final Observable parent) { - return new ReplayCallable(parent); + public static Supplier> replaySupplier(final Observable parent) { + return new ReplaySupplier(parent); } - public static Callable> replayCallable(final Observable parent, final int bufferSize) { - return new BufferedReplayCallable(parent, bufferSize); + public static Supplier> replaySupplier(final Observable parent, final int bufferSize) { + return new BufferedReplaySupplier(parent, bufferSize); } - public static Callable> replayCallable(final Observable parent, final int bufferSize, final long time, final TimeUnit unit, final Scheduler scheduler) { - return new BufferedTimedReplayCallable(parent, bufferSize, time, unit, scheduler); + public static Supplier> replaySupplier(final Observable parent, final int bufferSize, final long time, final TimeUnit unit, final Scheduler scheduler) { + return new BufferedTimedReplaySupplier(parent, bufferSize, time, unit, scheduler); } - public static Callable> replayCallable(final Observable parent, final long time, final TimeUnit unit, final Scheduler scheduler) { + public static Supplier> replaySupplier(final Observable parent, final long time, final TimeUnit unit, final Scheduler scheduler) { return new TimedReplayCallable(parent, time, unit, scheduler); } @@ -236,42 +236,42 @@ public static Function>, ObservableSou return new ZipIterableFunction(zipper); } - static final class ReplayCallable implements Callable> { + static final class ReplaySupplier implements Supplier> { private final Observable parent; - ReplayCallable(Observable parent) { + ReplaySupplier(Observable parent) { this.parent = parent; } @Override - public ConnectableObservable call() { + public ConnectableObservable get() { return parent.replay(); } } - static final class BufferedReplayCallable implements Callable> { + static final class BufferedReplaySupplier implements Supplier> { private final Observable parent; private final int bufferSize; - BufferedReplayCallable(Observable parent, int bufferSize) { + BufferedReplaySupplier(Observable parent, int bufferSize) { this.parent = parent; this.bufferSize = bufferSize; } @Override - public ConnectableObservable call() { + public ConnectableObservable get() { return parent.replay(bufferSize); } } - static final class BufferedTimedReplayCallable implements Callable> { + static final class BufferedTimedReplaySupplier implements Supplier> { private final Observable parent; private final int bufferSize; private final long time; private final TimeUnit unit; private final Scheduler scheduler; - BufferedTimedReplayCallable(Observable parent, int bufferSize, long time, TimeUnit unit, Scheduler scheduler) { + BufferedTimedReplaySupplier(Observable parent, int bufferSize, long time, TimeUnit unit, Scheduler scheduler) { this.parent = parent; this.bufferSize = bufferSize; this.time = time; @@ -280,12 +280,12 @@ static final class BufferedTimedReplayCallable implements Callable call() { + public ConnectableObservable get() { return parent.replay(bufferSize, time, unit, scheduler); } } - static final class TimedReplayCallable implements Callable> { + static final class TimedReplayCallable implements Supplier> { private final Observable parent; private final long time; private final TimeUnit unit; @@ -299,7 +299,7 @@ static final class TimedReplayCallable implements Callable call() { + public ConnectableObservable get() { return parent.replay(time, unit, scheduler); } } @@ -314,7 +314,7 @@ static final class ReplayFunction implements Function, Obser } @Override - public ObservableSource apply(Observable t) throws Exception { + public ObservableSource apply(Observable t) throws Throwable { ObservableSource apply = ObjectHelper.requireNonNull(selector.apply(t), "The selector returned a null ObservableSource"); return Observable.wrap(apply).observeOn(scheduler); } diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableJust.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableJust.java index 0ae53fb597..e006868eae 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableJust.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableJust.java @@ -14,14 +14,14 @@ package io.reactivex.internal.operators.observable; import io.reactivex.*; -import io.reactivex.internal.fuseable.ScalarCallable; +import io.reactivex.internal.fuseable.ScalarSupplier; import io.reactivex.internal.operators.observable.ObservableScalarXMap.ScalarDisposable; /** * Represents a constant scalar value. * @param the value type */ -public final class ObservableJust extends Observable implements ScalarCallable { +public final class ObservableJust extends Observable implements ScalarSupplier { private final T value; public ObservableJust(final T value) { @@ -36,7 +36,7 @@ protected void subscribeActual(Observer observer) { } @Override - public T call() { + public T get() { return value; } } diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableMap.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableMap.java index 475963ce85..724083356f 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableMap.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableMap.java @@ -69,7 +69,7 @@ public int requestFusion(int mode) { @Nullable @Override - public U poll() throws Exception { + public U poll() throws Throwable { T t = qd.poll(); return t != null ? ObjectHelper.requireNonNull(mapper.apply(t), "The mapper function returned a null value.") : null; } diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableMapNotification.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableMapNotification.java index f4418e9927..b7526db5f4 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableMapNotification.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableMapNotification.java @@ -13,12 +13,10 @@ package io.reactivex.internal.operators.observable; -import java.util.concurrent.Callable; - import io.reactivex.*; import io.reactivex.disposables.Disposable; import io.reactivex.exceptions.*; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; import io.reactivex.internal.disposables.DisposableHelper; import io.reactivex.internal.functions.ObjectHelper; @@ -26,13 +24,13 @@ public final class ObservableMapNotification extends AbstractObservableWit final Function> onNextMapper; final Function> onErrorMapper; - final Callable> onCompleteSupplier; + final Supplier> onCompleteSupplier; public ObservableMapNotification( ObservableSource source, Function> onNextMapper, Function> onErrorMapper, - Callable> onCompleteSupplier) { + Supplier> onCompleteSupplier) { super(source); this.onNextMapper = onNextMapper; this.onErrorMapper = onErrorMapper; @@ -49,14 +47,14 @@ static final class MapNotificationObserver final Observer> downstream; final Function> onNextMapper; final Function> onErrorMapper; - final Callable> onCompleteSupplier; + final Supplier> onCompleteSupplier; Disposable upstream; MapNotificationObserver(Observer> actual, Function> onNextMapper, Function> onErrorMapper, - Callable> onCompleteSupplier) { + Supplier> onCompleteSupplier) { this.downstream = actual; this.onNextMapper = onNextMapper; this.onErrorMapper = onErrorMapper; @@ -117,7 +115,7 @@ public void onComplete() { ObservableSource p; try { - p = ObjectHelper.requireNonNull(onCompleteSupplier.call(), "The onComplete ObservableSource returned is null"); + p = ObjectHelper.requireNonNull(onCompleteSupplier.get(), "The onComplete ObservableSource returned is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); downstream.onError(e); diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableObserveOn.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableObserveOn.java index abf1f0bb85..5a159feaf4 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableObserveOn.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableObserveOn.java @@ -304,7 +304,7 @@ public int requestFusion(int mode) { @Nullable @Override - public T poll() throws Exception { + public T poll() throws Throwable { return queue.poll(); } diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableReduceWithSingle.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableReduceWithSingle.java index bf492b5b28..7d7d0061f6 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableReduceWithSingle.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableReduceWithSingle.java @@ -13,11 +13,9 @@ package io.reactivex.internal.operators.observable; -import java.util.concurrent.Callable; - import io.reactivex.*; import io.reactivex.exceptions.Exceptions; -import io.reactivex.functions.BiFunction; +import io.reactivex.functions.*; import io.reactivex.internal.disposables.EmptyDisposable; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.operators.observable.ObservableReduceSeedSingle.ReduceSeedObserver; @@ -33,11 +31,11 @@ public final class ObservableReduceWithSingle extends Single { final ObservableSource source; - final Callable seedSupplier; + final Supplier seedSupplier; final BiFunction reducer; - public ObservableReduceWithSingle(ObservableSource source, Callable seedSupplier, BiFunction reducer) { + public ObservableReduceWithSingle(ObservableSource source, Supplier seedSupplier, BiFunction reducer) { this.source = source; this.seedSupplier = seedSupplier; this.reducer = reducer; @@ -48,7 +46,7 @@ protected void subscribeActual(SingleObserver observer) { R seed; try { - seed = ObjectHelper.requireNonNull(seedSupplier.call(), "The seedSupplier returned a null value"); + seed = ObjectHelper.requireNonNull(seedSupplier.get(), "The seedSupplier returned a null value"); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); EmptyDisposable.error(ex, observer); diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableReplay.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableReplay.java index 197ada9706..11180bdefb 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableReplay.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableReplay.java @@ -14,7 +14,7 @@ package io.reactivex.internal.operators.observable; import java.util.*; -import java.util.concurrent.*; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.*; import io.reactivex.*; @@ -58,7 +58,7 @@ interface BufferSupplier { * @return the new Observable instance */ public static Observable multicastSelector( - final Callable> connectableFactory, + final Supplier> connectableFactory, final Function, ? extends ObservableSource> selector) { return RxJavaPlugins.onAssembly(new MulticastReplay(connectableFactory, selector)); } @@ -1026,10 +1026,10 @@ public void subscribe(Observer child) { } static final class MulticastReplay extends Observable { - private final Callable> connectableFactory; + private final Supplier> connectableFactory; private final Function, ? extends ObservableSource> selector; - MulticastReplay(Callable> connectableFactory, Function, ? extends ObservableSource> selector) { + MulticastReplay(Supplier> connectableFactory, Function, ? extends ObservableSource> selector) { this.connectableFactory = connectableFactory; this.selector = selector; } @@ -1039,7 +1039,7 @@ protected void subscribeActual(Observer child) { ConnectableObservable co; ObservableSource observable; try { - co = ObjectHelper.requireNonNull(connectableFactory.call(), "The connectableFactory returned a null ConnectableObservable"); + co = ObjectHelper.requireNonNull(connectableFactory.get(), "The connectableFactory returned a null ConnectableObservable"); observable = ObjectHelper.requireNonNull(selector.apply(co), "The selector returned a null ObservableSource"); } catch (Throwable e) { Exceptions.throwIfFatal(e); diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableScalarXMap.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableScalarXMap.java index d58437900c..237661f1da 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableScalarXMap.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableScalarXMap.java @@ -13,13 +13,12 @@ package io.reactivex.internal.operators.observable; -import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicInteger; import io.reactivex.*; import io.reactivex.annotations.Nullable; import io.reactivex.exceptions.Exceptions; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; import io.reactivex.internal.disposables.EmptyDisposable; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.fuseable.QueueDisposable; @@ -36,7 +35,7 @@ private ObservableScalarXMap() { } /** - * Tries to subscribe to a possibly Callable source's mapped ObservableSource. + * Tries to subscribe to a possibly Supplier source's mapped ObservableSource. * @param the input value type * @param the output value type * @param source the source ObservableSource @@ -48,11 +47,11 @@ private ObservableScalarXMap() { public static boolean tryScalarXMapSubscribe(ObservableSource source, Observer observer, Function> mapper) { - if (source instanceof Callable) { + if (source instanceof Supplier) { T t; try { - t = ((Callable)source).call(); + t = ((Supplier)source).get(); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); EmptyDisposable.error(ex, observer); @@ -74,11 +73,11 @@ public static boolean tryScalarXMapSubscribe(ObservableSource source, return true; } - if (r instanceof Callable) { + if (r instanceof Supplier) { R u; try { - u = ((Callable)r).call(); + u = ((Supplier)r).get(); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); EmptyDisposable.error(ex, observer); @@ -144,11 +143,11 @@ public void subscribeActual(Observer observer) { EmptyDisposable.error(e, observer); return; } - if (other instanceof Callable) { + if (other instanceof Supplier) { R u; try { - u = ((Callable)other).call(); + u = ((Supplier)other).get(); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); EmptyDisposable.error(ex, observer); diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableScanSeed.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableScanSeed.java index a9b4a63716..369e87c790 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableScanSeed.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableScanSeed.java @@ -12,21 +12,19 @@ */ package io.reactivex.internal.operators.observable; -import io.reactivex.internal.functions.ObjectHelper; -import java.util.concurrent.Callable; - import io.reactivex.*; import io.reactivex.disposables.Disposable; import io.reactivex.exceptions.Exceptions; -import io.reactivex.functions.BiFunction; +import io.reactivex.functions.*; import io.reactivex.internal.disposables.*; +import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.plugins.RxJavaPlugins; public final class ObservableScanSeed extends AbstractObservableWithUpstream { final BiFunction accumulator; - final Callable seedSupplier; + final Supplier seedSupplier; - public ObservableScanSeed(ObservableSource source, Callable seedSupplier, BiFunction accumulator) { + public ObservableScanSeed(ObservableSource source, Supplier seedSupplier, BiFunction accumulator) { super(source); this.accumulator = accumulator; this.seedSupplier = seedSupplier; @@ -37,7 +35,7 @@ public void subscribeActual(Observer t) { R r; try { - r = ObjectHelper.requireNonNull(seedSupplier.call(), "The seed supplied is null"); + r = ObjectHelper.requireNonNull(seedSupplier.get(), "The seed supplied is null"); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptyDisposable.error(e, t); diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableToList.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableToList.java index afeee5399d..a4634abf93 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableToList.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableToList.java @@ -14,26 +14,26 @@ package io.reactivex.internal.operators.observable; import java.util.Collection; -import java.util.concurrent.Callable; import io.reactivex.*; import io.reactivex.disposables.Disposable; import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.Supplier; import io.reactivex.internal.disposables.*; import io.reactivex.internal.functions.*; public final class ObservableToList> extends AbstractObservableWithUpstream { - final Callable collectionSupplier; + final Supplier collectionSupplier; @SuppressWarnings({ "unchecked", "rawtypes" }) public ObservableToList(ObservableSource source, final int defaultCapacityHint) { super(source); - this.collectionSupplier = (Callable)Functions.createArrayList(defaultCapacityHint); + this.collectionSupplier = (Supplier)Functions.createArrayList(defaultCapacityHint); } - public ObservableToList(ObservableSource source, Callable collectionSupplier) { + public ObservableToList(ObservableSource source, Supplier collectionSupplier) { super(source); this.collectionSupplier = collectionSupplier; } @@ -42,7 +42,7 @@ public ObservableToList(ObservableSource source, Callable collectionSuppli public void subscribeActual(Observer t) { U coll; try { - coll = ObjectHelper.requireNonNull(collectionSupplier.call(), "The collectionSupplier returned a null collection. Null values are generally not allowed in 2.x operators and sources."); + coll = ObjectHelper.requireNonNull(collectionSupplier.get(), "The collectionSupplier returned a null collection. Null values are generally not allowed in 2.x operators and sources."); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptyDisposable.error(e, t); diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableToListSingle.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableToListSingle.java index 410af1e161..9ba43848d5 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableToListSingle.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableToListSingle.java @@ -13,17 +13,14 @@ package io.reactivex.internal.operators.observable; -import io.reactivex.internal.functions.ObjectHelper; -import java.util.*; -import java.util.concurrent.Callable; +import java.util.Collection; import io.reactivex.*; -import io.reactivex.Observable; -import io.reactivex.Observer; import io.reactivex.disposables.Disposable; import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.Supplier; import io.reactivex.internal.disposables.*; -import io.reactivex.internal.functions.Functions; +import io.reactivex.internal.functions.*; import io.reactivex.internal.fuseable.FuseToObservable; import io.reactivex.plugins.RxJavaPlugins; @@ -32,15 +29,15 @@ public final class ObservableToListSingle> final ObservableSource source; - final Callable collectionSupplier; + final Supplier collectionSupplier; @SuppressWarnings({ "unchecked", "rawtypes" }) public ObservableToListSingle(ObservableSource source, final int defaultCapacityHint) { this.source = source; - this.collectionSupplier = (Callable)Functions.createArrayList(defaultCapacityHint); + this.collectionSupplier = (Supplier)Functions.createArrayList(defaultCapacityHint); } - public ObservableToListSingle(ObservableSource source, Callable collectionSupplier) { + public ObservableToListSingle(ObservableSource source, Supplier collectionSupplier) { this.source = source; this.collectionSupplier = collectionSupplier; } @@ -49,7 +46,7 @@ public ObservableToListSingle(ObservableSource source, Callable collection public void subscribeActual(SingleObserver t) { U coll; try { - coll = ObjectHelper.requireNonNull(collectionSupplier.call(), "The collectionSupplier returned a null collection. Null values are generally not allowed in 2.x operators and sources."); + coll = ObjectHelper.requireNonNull(collectionSupplier.get(), "The collectionSupplier returned a null collection. Null values are generally not allowed in 2.x operators and sources."); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptyDisposable.error(e, t); diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableUsing.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableUsing.java index 46806ae0dc..0571f4293c 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableUsing.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableUsing.java @@ -13,7 +13,6 @@ package io.reactivex.internal.operators.observable; -import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicBoolean; import io.reactivex.*; @@ -25,12 +24,12 @@ import io.reactivex.plugins.RxJavaPlugins; public final class ObservableUsing extends Observable { - final Callable resourceSupplier; + final Supplier resourceSupplier; final Function> sourceSupplier; final Consumer disposer; final boolean eager; - public ObservableUsing(Callable resourceSupplier, + public ObservableUsing(Supplier resourceSupplier, Function> sourceSupplier, Consumer disposer, boolean eager) { @@ -45,7 +44,7 @@ public void subscribeActual(Observer observer) { D resource; try { - resource = resourceSupplier.call(); + resource = resourceSupplier.get(); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptyDisposable.error(e, observer); diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableWindowBoundarySupplier.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableWindowBoundarySupplier.java index c2d319032b..f8ef619397 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableWindowBoundarySupplier.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableWindowBoundarySupplier.java @@ -13,12 +13,12 @@ package io.reactivex.internal.operators.observable; -import java.util.concurrent.Callable; import java.util.concurrent.atomic.*; import io.reactivex.*; import io.reactivex.disposables.Disposable; import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.Supplier; import io.reactivex.internal.disposables.DisposableHelper; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.queue.MpscLinkedQueue; @@ -28,12 +28,12 @@ import io.reactivex.subjects.UnicastSubject; public final class ObservableWindowBoundarySupplier extends AbstractObservableWithUpstream> { - final Callable> other; + final Supplier> other; final int capacityHint; public ObservableWindowBoundarySupplier( ObservableSource source, - Callable> other, int capacityHint) { + Supplier> other, int capacityHint) { super(source); this.other = other; this.capacityHint = capacityHint; @@ -68,7 +68,7 @@ static final class WindowBoundaryMainObserver final AtomicBoolean stopWindows; - final Callable> other; + final Supplier> other; static final Object NEXT_WINDOW = new Object(); @@ -78,7 +78,7 @@ static final class WindowBoundaryMainObserver UnicastSubject window; - WindowBoundaryMainObserver(Observer> downstream, int capacityHint, Callable> other) { + WindowBoundaryMainObserver(Observer> downstream, int capacityHint, Supplier> other) { this.downstream = downstream; this.capacityHint = capacityHint; this.boundaryObserver = new AtomicReference>(); @@ -254,7 +254,7 @@ void drain() { ObservableSource otherSource; try { - otherSource = ObjectHelper.requireNonNull(other.call(), "The other Callable returned a null ObservableSource"); + otherSource = ObjectHelper.requireNonNull(other.get(), "The other Supplier returned a null ObservableSource"); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); errors.addThrowable(ex); diff --git a/src/main/java/io/reactivex/internal/operators/observable/ObservableWithLatestFromMany.java b/src/main/java/io/reactivex/internal/operators/observable/ObservableWithLatestFromMany.java index 194d33c61c..8e88f7f92e 100644 --- a/src/main/java/io/reactivex/internal/operators/observable/ObservableWithLatestFromMany.java +++ b/src/main/java/io/reactivex/internal/operators/observable/ObservableWithLatestFromMany.java @@ -285,7 +285,7 @@ public void dispose() { final class SingletonArrayFunc implements Function { @Override - public R apply(T t) throws Exception { + public R apply(T t) throws Throwable { return ObjectHelper.requireNonNull(combiner.apply(new Object[] { t }), "The combiner returned a null value"); } } diff --git a/src/main/java/io/reactivex/internal/operators/parallel/ParallelCollect.java b/src/main/java/io/reactivex/internal/operators/parallel/ParallelCollect.java index b1052b2fd6..6f1bfb7d79 100644 --- a/src/main/java/io/reactivex/internal/operators/parallel/ParallelCollect.java +++ b/src/main/java/io/reactivex/internal/operators/parallel/ParallelCollect.java @@ -13,12 +13,10 @@ package io.reactivex.internal.operators.parallel; -import java.util.concurrent.Callable; - import org.reactivestreams.*; import io.reactivex.exceptions.Exceptions; -import io.reactivex.functions.BiConsumer; +import io.reactivex.functions.*; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.subscribers.DeferredScalarSubscriber; import io.reactivex.internal.subscriptions.*; @@ -35,12 +33,12 @@ public final class ParallelCollect extends ParallelFlowable { final ParallelFlowable source; - final Callable initialCollection; + final Supplier initialCollection; final BiConsumer collector; public ParallelCollect(ParallelFlowable source, - Callable initialCollection, BiConsumer collector) { + Supplier initialCollection, BiConsumer collector) { this.source = source; this.initialCollection = initialCollection; this.collector = collector; @@ -61,7 +59,7 @@ public void subscribe(Subscriber[] subscribers) { C initialValue; try { - initialValue = ObjectHelper.requireNonNull(initialCollection.call(), "The initialSupplier returned a null value"); + initialValue = ObjectHelper.requireNonNull(initialCollection.get(), "The initialSupplier returned a null value"); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); reportError(subscribers, ex); diff --git a/src/main/java/io/reactivex/internal/operators/parallel/ParallelReduce.java b/src/main/java/io/reactivex/internal/operators/parallel/ParallelReduce.java index 0c3bcfbba1..d27b7b64a6 100644 --- a/src/main/java/io/reactivex/internal/operators/parallel/ParallelReduce.java +++ b/src/main/java/io/reactivex/internal/operators/parallel/ParallelReduce.java @@ -13,12 +13,10 @@ package io.reactivex.internal.operators.parallel; -import java.util.concurrent.Callable; - import org.reactivestreams.*; import io.reactivex.exceptions.Exceptions; -import io.reactivex.functions.BiFunction; +import io.reactivex.functions.*; import io.reactivex.internal.functions.ObjectHelper; import io.reactivex.internal.subscribers.DeferredScalarSubscriber; import io.reactivex.internal.subscriptions.*; @@ -35,11 +33,11 @@ public final class ParallelReduce extends ParallelFlowable { final ParallelFlowable source; - final Callable initialSupplier; + final Supplier initialSupplier; final BiFunction reducer; - public ParallelReduce(ParallelFlowable source, Callable initialSupplier, BiFunction reducer) { + public ParallelReduce(ParallelFlowable source, Supplier initialSupplier, BiFunction reducer) { this.source = source; this.initialSupplier = initialSupplier; this.reducer = reducer; @@ -60,7 +58,7 @@ public void subscribe(Subscriber[] subscribers) { R initialValue; try { - initialValue = ObjectHelper.requireNonNull(initialSupplier.call(), "The initialSupplier returned a null value"); + initialValue = ObjectHelper.requireNonNull(initialSupplier.get(), "The initialSupplier returned a null value"); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); reportError(subscribers, ex); diff --git a/src/main/java/io/reactivex/internal/operators/single/SingleDefer.java b/src/main/java/io/reactivex/internal/operators/single/SingleDefer.java index 0f7a66dc38..3c4536c911 100644 --- a/src/main/java/io/reactivex/internal/operators/single/SingleDefer.java +++ b/src/main/java/io/reactivex/internal/operators/single/SingleDefer.java @@ -13,18 +13,17 @@ package io.reactivex.internal.operators.single; -import java.util.concurrent.Callable; - import io.reactivex.*; import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.Supplier; import io.reactivex.internal.disposables.EmptyDisposable; import io.reactivex.internal.functions.ObjectHelper; public final class SingleDefer extends Single { - final Callable> singleSupplier; + final Supplier> singleSupplier; - public SingleDefer(Callable> singleSupplier) { + public SingleDefer(Supplier> singleSupplier) { this.singleSupplier = singleSupplier; } @@ -33,7 +32,7 @@ protected void subscribeActual(SingleObserver observer) { SingleSource next; try { - next = ObjectHelper.requireNonNull(singleSupplier.call(), "The singleSupplier returned a null SingleSource"); + next = ObjectHelper.requireNonNull(singleSupplier.get(), "The singleSupplier returned a null SingleSource"); } catch (Throwable e) { Exceptions.throwIfFatal(e); EmptyDisposable.error(e, observer); diff --git a/src/main/java/io/reactivex/internal/operators/single/SingleError.java b/src/main/java/io/reactivex/internal/operators/single/SingleError.java index 6a6e1aef5a..b832dc8fdc 100644 --- a/src/main/java/io/reactivex/internal/operators/single/SingleError.java +++ b/src/main/java/io/reactivex/internal/operators/single/SingleError.java @@ -13,18 +13,17 @@ package io.reactivex.internal.operators.single; -import io.reactivex.internal.functions.ObjectHelper; -import java.util.concurrent.Callable; - import io.reactivex.*; import io.reactivex.exceptions.Exceptions; +import io.reactivex.functions.Supplier; import io.reactivex.internal.disposables.EmptyDisposable; +import io.reactivex.internal.functions.ObjectHelper; public final class SingleError extends Single { - final Callable errorSupplier; + final Supplier errorSupplier; - public SingleError(Callable errorSupplier) { + public SingleError(Supplier errorSupplier) { this.errorSupplier = errorSupplier; } @@ -33,7 +32,7 @@ protected void subscribeActual(SingleObserver observer) { Throwable error; try { - error = ObjectHelper.requireNonNull(errorSupplier.call(), "Callable returned null throwable. Null values are generally not allowed in 2.x operators and sources."); + error = ObjectHelper.requireNonNull(errorSupplier.get(), "Supplier returned null throwable. Null values are generally not allowed in 2.x operators and sources."); } catch (Throwable e) { Exceptions.throwIfFatal(e); error = e; diff --git a/src/main/java/io/reactivex/internal/operators/single/SingleInternalHelper.java b/src/main/java/io/reactivex/internal/operators/single/SingleInternalHelper.java index 7770fd38b4..e4345635ce 100644 --- a/src/main/java/io/reactivex/internal/operators/single/SingleInternalHelper.java +++ b/src/main/java/io/reactivex/internal/operators/single/SingleInternalHelper.java @@ -20,7 +20,7 @@ import io.reactivex.*; import io.reactivex.Observable; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; /** * Helper utility class to support Single with inner classes. @@ -32,16 +32,21 @@ private SingleInternalHelper() { throw new IllegalStateException("No instances!"); } - enum NoSuchElementCallable implements Callable { + enum NoSuchElementCallable implements Supplier, Callable { INSTANCE; @Override public NoSuchElementException call() throws Exception { return new NoSuchElementException(); } + + @Override + public NoSuchElementException get() throws Throwable { + return new NoSuchElementException(); + } } - public static Callable emptyThrower() { + public static Supplier emptyThrower() { return NoSuchElementCallable.INSTANCE; } diff --git a/src/main/java/io/reactivex/internal/operators/single/SingleUsing.java b/src/main/java/io/reactivex/internal/operators/single/SingleUsing.java index 0352bddb63..8973d4f59c 100644 --- a/src/main/java/io/reactivex/internal/operators/single/SingleUsing.java +++ b/src/main/java/io/reactivex/internal/operators/single/SingleUsing.java @@ -13,7 +13,6 @@ package io.reactivex.internal.operators.single; -import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicReference; import io.reactivex.*; @@ -26,12 +25,12 @@ public final class SingleUsing extends Single { - final Callable resourceSupplier; + final Supplier resourceSupplier; final Function> singleFunction; final Consumer disposer; final boolean eager; - public SingleUsing(Callable resourceSupplier, + public SingleUsing(Supplier resourceSupplier, Function> singleFunction, Consumer disposer, boolean eager) { @@ -47,7 +46,7 @@ protected void subscribeActual(final SingleObserver observer) { final U resource; // NOPMD try { - resource = resourceSupplier.call(); + resource = resourceSupplier.get(); } catch (Throwable ex) { Exceptions.throwIfFatal(ex); EmptyDisposable.error(ex, observer); diff --git a/src/main/java/io/reactivex/internal/operators/single/SingleZipArray.java b/src/main/java/io/reactivex/internal/operators/single/SingleZipArray.java index 31fd470ecd..211e4b93b5 100644 --- a/src/main/java/io/reactivex/internal/operators/single/SingleZipArray.java +++ b/src/main/java/io/reactivex/internal/operators/single/SingleZipArray.java @@ -178,7 +178,7 @@ public void onError(Throwable e) { final class SingletonArrayFunc implements Function { @Override - public R apply(T t) throws Exception { + public R apply(T t) throws Throwable { return ObjectHelper.requireNonNull(zipper.apply(new Object[] { t }), "The zipper returned a null value"); } } diff --git a/src/main/java/io/reactivex/internal/operators/single/SingleZipIterable.java b/src/main/java/io/reactivex/internal/operators/single/SingleZipIterable.java index 6936642225..50f66100e9 100644 --- a/src/main/java/io/reactivex/internal/operators/single/SingleZipIterable.java +++ b/src/main/java/io/reactivex/internal/operators/single/SingleZipIterable.java @@ -81,7 +81,7 @@ protected void subscribeActual(SingleObserver observer) { final class SingletonArrayFunc implements Function { @Override - public R apply(T t) throws Exception { + public R apply(T t) throws Throwable { return ObjectHelper.requireNonNull(zipper.apply(new Object[] { t }), "The zipper returned a null value"); } } diff --git a/src/main/java/io/reactivex/internal/util/AppendOnlyLinkedArrayList.java b/src/main/java/io/reactivex/internal/util/AppendOnlyLinkedArrayList.java index 12c4d062c0..ed2c02ae23 100644 --- a/src/main/java/io/reactivex/internal/util/AppendOnlyLinkedArrayList.java +++ b/src/main/java/io/reactivex/internal/util/AppendOnlyLinkedArrayList.java @@ -161,7 +161,7 @@ public boolean accept(Observer observer) { * @throws Exception if the predicate throws */ @SuppressWarnings("unchecked") - public void forEachWhile(S state, BiPredicate consumer) throws Exception { + public void forEachWhile(S state, BiPredicate consumer) throws Throwable { Object[] a = head; final int c = capacity; for (;;) { diff --git a/src/main/java/io/reactivex/internal/util/ArrayListSupplier.java b/src/main/java/io/reactivex/internal/util/ArrayListSupplier.java index 1787d16872..918cab0327 100644 --- a/src/main/java/io/reactivex/internal/util/ArrayListSupplier.java +++ b/src/main/java/io/reactivex/internal/util/ArrayListSupplier.java @@ -14,16 +14,15 @@ package io.reactivex.internal.util; import java.util.*; -import java.util.concurrent.Callable; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; -public enum ArrayListSupplier implements Callable>, Function> { +public enum ArrayListSupplier implements Supplier>, Function> { INSTANCE; @SuppressWarnings({ "unchecked", "rawtypes" }) - public static Callable> asCallable() { - return (Callable)INSTANCE; + public static Supplier> asSupplier() { + return (Supplier)INSTANCE; } @SuppressWarnings({ "unchecked", "rawtypes" }) @@ -32,11 +31,11 @@ public static Function> asFunction() { } @Override - public List call() throws Exception { + public List get() { return new ArrayList(); } - @Override public List apply(Object o) throws Exception { + @Override public List apply(Object o) { return new ArrayList(); } } diff --git a/src/main/java/io/reactivex/internal/util/HashMapSupplier.java b/src/main/java/io/reactivex/internal/util/HashMapSupplier.java index 79394e629a..18b92c7a35 100644 --- a/src/main/java/io/reactivex/internal/util/HashMapSupplier.java +++ b/src/main/java/io/reactivex/internal/util/HashMapSupplier.java @@ -13,19 +13,19 @@ package io.reactivex.internal.util; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.Callable; +import java.util.*; -public enum HashMapSupplier implements Callable> { +import io.reactivex.functions.Supplier; + +public enum HashMapSupplier implements Supplier> { INSTANCE; @SuppressWarnings({ "unchecked", "rawtypes" }) - public static Callable> asCallable() { - return (Callable)INSTANCE; + public static Supplier> asSupplier() { + return (Supplier)INSTANCE; } - @Override public Map call() throws Exception { + @Override public Map get() { return new HashMap(); } } diff --git a/src/main/java/io/reactivex/observers/BaseTestConsumer.java b/src/main/java/io/reactivex/observers/BaseTestConsumer.java index 61db5a2356..8560830919 100644 --- a/src/main/java/io/reactivex/observers/BaseTestConsumer.java +++ b/src/main/java/io/reactivex/observers/BaseTestConsumer.java @@ -326,7 +326,7 @@ public final U assertError(Predicate errorPredicate) { found = true; break; } - } catch (Exception ex) { + } catch (Throwable ex) { throw ExceptionHelper.wrapOrThrow(ex); } } @@ -421,7 +421,7 @@ public final U assertNever(Predicate valuePredicate) { if (valuePredicate.test(v)) { throw fail("Value at position " + i + " matches predicate " + valuePredicate.toString() + ", which was not expected."); } - } catch (Exception ex) { + } catch (Throwable ex) { throw ExceptionHelper.wrapOrThrow(ex); } } @@ -481,7 +481,7 @@ public final U assertValueAt(int index, Predicate valuePredicate) { if (valuePredicate.test(values.get(index))) { found = true; } - } catch (Exception ex) { + } catch (Throwable ex) { throw ExceptionHelper.wrapOrThrow(ex); } diff --git a/src/main/java/io/reactivex/parallel/ParallelFlowable.java b/src/main/java/io/reactivex/parallel/ParallelFlowable.java index 13ebb021a4..26eb676f22 100644 --- a/src/main/java/io/reactivex/parallel/ParallelFlowable.java +++ b/src/main/java/io/reactivex/parallel/ParallelFlowable.java @@ -14,7 +14,6 @@ package io.reactivex.parallel; import java.util.*; -import java.util.concurrent.Callable; import io.reactivex.*; import io.reactivex.annotations.*; @@ -330,7 +329,7 @@ public final Flowable reduce(@NonNull BiFunction reducer) { */ @CheckReturnValue @NonNull - public final ParallelFlowable reduce(@NonNull Callable initialSupplier, @NonNull BiFunction reducer) { + public final ParallelFlowable reduce(@NonNull Supplier initialSupplier, @NonNull BiFunction reducer) { ObjectHelper.requireNonNull(initialSupplier, "initialSupplier"); ObjectHelper.requireNonNull(reducer, "reducer"); return RxJavaPlugins.onAssembly(new ParallelReduce(this, initialSupplier, reducer)); @@ -738,7 +737,7 @@ public final ParallelFlowable doOnCancel(@NonNull Action onCancel) { */ @CheckReturnValue @NonNull - public final ParallelFlowable collect(@NonNull Callable collectionSupplier, @NonNull BiConsumer collector) { + public final ParallelFlowable collect(@NonNull Supplier collectionSupplier, @NonNull BiConsumer collector) { ObjectHelper.requireNonNull(collectionSupplier, "collectionSupplier is null"); ObjectHelper.requireNonNull(collector, "collector is null"); return RxJavaPlugins.onAssembly(new ParallelCollect(this, collectionSupplier, collector)); diff --git a/src/main/java/io/reactivex/plugins/RxJavaPlugins.java b/src/main/java/io/reactivex/plugins/RxJavaPlugins.java index 1d3a810cc5..8c696711ac 100644 --- a/src/main/java/io/reactivex/plugins/RxJavaPlugins.java +++ b/src/main/java/io/reactivex/plugins/RxJavaPlugins.java @@ -39,16 +39,16 @@ public final class RxJavaPlugins { static volatile Function onScheduleHandler; @Nullable - static volatile Function, ? extends Scheduler> onInitComputationHandler; + static volatile Function, ? extends Scheduler> onInitComputationHandler; @Nullable - static volatile Function, ? extends Scheduler> onInitSingleHandler; + static volatile Function, ? extends Scheduler> onInitSingleHandler; @Nullable - static volatile Function, ? extends Scheduler> onInitIoHandler; + static volatile Function, ? extends Scheduler> onInitIoHandler; @Nullable - static volatile Function, ? extends Scheduler> onInitNewThreadHandler; + static volatile Function, ? extends Scheduler> onInitNewThreadHandler; @Nullable static volatile Function onComputationHandler; @@ -191,7 +191,7 @@ public static Consumer getErrorHandler() { * @return the hook function, may be null */ @Nullable - public static Function, ? extends Scheduler> getInitComputationSchedulerHandler() { + public static Function, ? extends Scheduler> getInitComputationSchedulerHandler() { return onInitComputationHandler; } @@ -200,7 +200,7 @@ public static Consumer getErrorHandler() { * @return the hook function, may be null */ @Nullable - public static Function, ? extends Scheduler> getInitIoSchedulerHandler() { + public static Function, ? extends Scheduler> getInitIoSchedulerHandler() { return onInitIoHandler; } @@ -209,7 +209,7 @@ public static Consumer getErrorHandler() { * @return the hook function, may be null */ @Nullable - public static Function, ? extends Scheduler> getInitNewThreadSchedulerHandler() { + public static Function, ? extends Scheduler> getInitNewThreadSchedulerHandler() { return onInitNewThreadHandler; } @@ -218,7 +218,7 @@ public static Consumer getErrorHandler() { * @return the hook function, may be null */ @Nullable - public static Function, ? extends Scheduler> getInitSingleSchedulerHandler() { + public static Function, ? extends Scheduler> getInitSingleSchedulerHandler() { return onInitSingleHandler; } @@ -260,14 +260,14 @@ public static Consumer getErrorHandler() { /** * Calls the associated hook function. - * @param defaultScheduler a {@link Callable} which returns the hook's input value + * @param defaultScheduler a {@link Supplier} which returns the hook's input value * @return the value returned by the hook, not null - * @throws NullPointerException if the callable parameter or its result are null + * @throws NullPointerException if the supplier parameter or its result are null */ @NonNull - public static Scheduler initComputationScheduler(@NonNull Callable defaultScheduler) { - ObjectHelper.requireNonNull(defaultScheduler, "Scheduler Callable can't be null"); - Function, ? extends Scheduler> f = onInitComputationHandler; + public static Scheduler initComputationScheduler(@NonNull Supplier defaultScheduler) { + ObjectHelper.requireNonNull(defaultScheduler, "Scheduler Supplier can't be null"); + Function, ? extends Scheduler> f = onInitComputationHandler; if (f == null) { return callRequireNonNull(defaultScheduler); } @@ -276,14 +276,14 @@ public static Scheduler initComputationScheduler(@NonNull Callable de /** * Calls the associated hook function. - * @param defaultScheduler a {@link Callable} which returns the hook's input value + * @param defaultScheduler a {@link Supplier} which returns the hook's input value * @return the value returned by the hook, not null - * @throws NullPointerException if the callable parameter or its result are null + * @throws NullPointerException if the supplier parameter or its result are null */ @NonNull - public static Scheduler initIoScheduler(@NonNull Callable defaultScheduler) { - ObjectHelper.requireNonNull(defaultScheduler, "Scheduler Callable can't be null"); - Function, ? extends Scheduler> f = onInitIoHandler; + public static Scheduler initIoScheduler(@NonNull Supplier defaultScheduler) { + ObjectHelper.requireNonNull(defaultScheduler, "Scheduler Supplier can't be null"); + Function, ? extends Scheduler> f = onInitIoHandler; if (f == null) { return callRequireNonNull(defaultScheduler); } @@ -292,14 +292,14 @@ public static Scheduler initIoScheduler(@NonNull Callable defaultSche /** * Calls the associated hook function. - * @param defaultScheduler a {@link Callable} which returns the hook's input value + * @param defaultScheduler a {@link Supplier} which returns the hook's input value * @return the value returned by the hook, not null - * @throws NullPointerException if the callable parameter or its result are null + * @throws NullPointerException if the supplier parameter or its result are null */ @NonNull - public static Scheduler initNewThreadScheduler(@NonNull Callable defaultScheduler) { - ObjectHelper.requireNonNull(defaultScheduler, "Scheduler Callable can't be null"); - Function, ? extends Scheduler> f = onInitNewThreadHandler; + public static Scheduler initNewThreadScheduler(@NonNull Supplier defaultScheduler) { + ObjectHelper.requireNonNull(defaultScheduler, "Scheduler Supplier can't be null"); + Function, ? extends Scheduler> f = onInitNewThreadHandler; if (f == null) { return callRequireNonNull(defaultScheduler); } @@ -308,14 +308,14 @@ public static Scheduler initNewThreadScheduler(@NonNull Callable defa /** * Calls the associated hook function. - * @param defaultScheduler a {@link Callable} which returns the hook's input value + * @param defaultScheduler a {@link Supplier} which returns the hook's input value * @return the value returned by the hook, not null - * @throws NullPointerException if the callable parameter or its result are null + * @throws NullPointerException if the supplier parameter or its result are null */ @NonNull - public static Scheduler initSingleScheduler(@NonNull Callable defaultScheduler) { - ObjectHelper.requireNonNull(defaultScheduler, "Scheduler Callable can't be null"); - Function, ? extends Scheduler> f = onInitSingleHandler; + public static Scheduler initSingleScheduler(@NonNull Supplier defaultScheduler) { + ObjectHelper.requireNonNull(defaultScheduler, "Scheduler Supplier can't be null"); + Function, ? extends Scheduler> f = onInitSingleHandler; if (f == null) { return callRequireNonNull(defaultScheduler); } @@ -556,7 +556,7 @@ public static void setErrorHandler(@Nullable Consumer handler * Sets the specific hook function. * @param handler the hook function to set, null allowed, but the function may not return null */ - public static void setInitComputationSchedulerHandler(@Nullable Function, ? extends Scheduler> handler) { + public static void setInitComputationSchedulerHandler(@Nullable Function, ? extends Scheduler> handler) { if (lockdown) { throw new IllegalStateException("Plugins can't be changed anymore"); } @@ -567,7 +567,7 @@ public static void setInitComputationSchedulerHandler(@Nullable Function, ? extends Scheduler> handler) { + public static void setInitIoSchedulerHandler(@Nullable Function, ? extends Scheduler> handler) { if (lockdown) { throw new IllegalStateException("Plugins can't be changed anymore"); } @@ -578,7 +578,7 @@ public static void setInitIoSchedulerHandler(@Nullable Function, ? extends Scheduler> handler) { + public static void setInitNewThreadSchedulerHandler(@Nullable Function, ? extends Scheduler> handler) { if (lockdown) { throw new IllegalStateException("Plugins can't be changed anymore"); } @@ -589,7 +589,7 @@ public static void setInitNewThreadSchedulerHandler(@Nullable Function, ? extends Scheduler> handler) { + public static void setInitSingleSchedulerHandler(@Nullable Function, ? extends Scheduler> handler) { if (lockdown) { throw new IllegalStateException("Plugins can't be changed anymore"); } @@ -1292,16 +1292,16 @@ static R apply(@NonNull BiFunction f, @NonNull T t, @NonNull } /** - * Wraps the call to the Scheduler creation callable in try-catch and propagates thrown + * Wraps the call to the Scheduler creation supplier in try-catch and propagates thrown * checked exceptions as RuntimeException and enforces that result is not null. - * @param s the {@link Callable} which returns a {@link Scheduler}, not null (not verified). Cannot return null - * @return the result of the callable call, not null - * @throws NullPointerException if the callable parameter returns null + * @param s the {@link Supplier} which returns a {@link Scheduler}, not null (not verified). Cannot return null + * @return the result of the supplier call, not null + * @throws NullPointerException if the supplier parameter returns null */ @NonNull - static Scheduler callRequireNonNull(@NonNull Callable s) { + static Scheduler callRequireNonNull(@NonNull Supplier s) { try { - return ObjectHelper.requireNonNull(s.call(), "Scheduler Callable result can't be null"); + return ObjectHelper.requireNonNull(s.get(), "Scheduler Supplier result can't be null"); } catch (Throwable ex) { throw ExceptionHelper.wrapOrThrow(ex); } @@ -1316,8 +1316,8 @@ static Scheduler callRequireNonNull(@NonNull Callable s) { * @throws NullPointerException if the function parameter returns null */ @NonNull - static Scheduler applyRequireNonNull(@NonNull Function, ? extends Scheduler> f, Callable s) { - return ObjectHelper.requireNonNull(apply(f, s), "Scheduler Callable result can't be null"); + static Scheduler applyRequireNonNull(@NonNull Function, ? extends Scheduler> f, Supplier s) { + return ObjectHelper.requireNonNull(apply(f, s), "Scheduler Supplier result can't be null"); } /** Helper class, no instances. */ diff --git a/src/main/java/io/reactivex/schedulers/Schedulers.java b/src/main/java/io/reactivex/schedulers/Schedulers.java index 9e070690b8..c9e6c42d11 100644 --- a/src/main/java/io/reactivex/schedulers/Schedulers.java +++ b/src/main/java/io/reactivex/schedulers/Schedulers.java @@ -17,6 +17,7 @@ import io.reactivex.Scheduler; import io.reactivex.annotations.*; +import io.reactivex.functions.Supplier; import io.reactivex.internal.schedulers.*; import io.reactivex.plugins.RxJavaPlugins; @@ -432,30 +433,30 @@ public static void start() { SchedulerPoolFactory.start(); } - static final class IOTask implements Callable { + static final class IOTask implements Supplier { @Override - public Scheduler call() throws Exception { + public Scheduler get() throws Exception { return IoHolder.DEFAULT; } } - static final class NewThreadTask implements Callable { + static final class NewThreadTask implements Supplier { @Override - public Scheduler call() throws Exception { + public Scheduler get() throws Exception { return NewThreadHolder.DEFAULT; } } - static final class SingleTask implements Callable { + static final class SingleTask implements Supplier { @Override - public Scheduler call() throws Exception { + public Scheduler get() throws Exception { return SingleHolder.DEFAULT; } } - static final class ComputationTask implements Callable { + static final class ComputationTask implements Supplier { @Override - public Scheduler call() throws Exception { + public Scheduler get() throws Exception { return ComputationHolder.DEFAULT; } } diff --git a/src/test/java/io/reactivex/TestHelper.java b/src/test/java/io/reactivex/TestHelper.java index 7d19b95b35..018b4e61ef 100644 --- a/src/test/java/io/reactivex/TestHelper.java +++ b/src/test/java/io/reactivex/TestHelper.java @@ -2998,7 +2998,7 @@ public boolean offer(T v1, T v2) { } @Override - public T poll() throws Exception { + public T poll() throws Throwable { return qs.poll(); } @@ -3103,7 +3103,7 @@ public boolean offer(T v1, T v2) { } @Override - public T poll() throws Exception { + public T poll() throws Throwable { return qd.poll(); } diff --git a/src/test/java/io/reactivex/completable/CompletableTest.java b/src/test/java/io/reactivex/completable/CompletableTest.java index 80f4b49d5a..420bbe3caf 100644 --- a/src/test/java/io/reactivex/completable/CompletableTest.java +++ b/src/test/java/io/reactivex/completable/CompletableTest.java @@ -64,8 +64,6 @@ public Completable next() { @Override public void remove() { - // TODO Auto-generated method stub - } }; } @@ -90,8 +88,6 @@ public Completable next() { @Override public void remove() { - // TODO Auto-generated method stub - } }; } @@ -308,9 +304,9 @@ public void concatObservableEmpty() { @Test(timeout = 5000, expected = TestException.class) public void concatObservableError() { - Completable c = Completable.concat(Flowable.error(new Callable() { + Completable c = Completable.concat(Flowable.error(new Supplier() { @Override - public Throwable call() { + public Throwable get() { return new TestException(); } })); @@ -413,9 +409,9 @@ public void subscribe(CompletableObserver observer) { @Test(timeout = 5000) public void defer() { - Completable c = Completable.defer(new Callable() { + Completable c = Completable.defer(new Supplier() { @Override - public Completable call() { + public Completable get() { return normal.completable; } }); @@ -434,9 +430,9 @@ public void deferNull() { @Test(timeout = 5000, expected = NullPointerException.class) public void deferReturnsNull() { - Completable c = Completable.defer(new Callable() { + Completable c = Completable.defer(new Supplier() { @Override - public Completable call() { + public Completable get() { return null; } }); @@ -446,9 +442,9 @@ public Completable call() { @Test(timeout = 5000, expected = TestException.class) public void deferFunctionThrows() { - Completable c = Completable.defer(new Callable() { + Completable c = Completable.defer(new Supplier() { @Override - public Completable call() { throw new TestException(); } + public Completable get() { throw new TestException(); } }); c.blockingAwait(); @@ -456,9 +452,9 @@ public void deferFunctionThrows() { @Test(timeout = 5000, expected = TestException.class) public void deferErrorSource() { - Completable c = Completable.defer(new Callable() { + Completable c = Completable.defer(new Supplier() { @Override - public Completable call() { + public Completable get() { return error.completable; } }); @@ -468,14 +464,14 @@ public Completable call() { @Test(expected = NullPointerException.class) public void errorSupplierNull() { - Completable.error((Callable)null); + Completable.error((Supplier)null); } @Test(timeout = 5000, expected = TestException.class) public void errorSupplierNormal() { - Completable c = Completable.error(new Callable() { + Completable c = Completable.error(new Supplier() { @Override - public Throwable call() { + public Throwable get() { return new TestException(); } }); @@ -485,9 +481,9 @@ public Throwable call() { @Test(timeout = 5000, expected = NullPointerException.class) public void errorSupplierReturnsNull() { - Completable c = Completable.error(new Callable() { + Completable c = Completable.error(new Supplier() { @Override - public Throwable call() { + public Throwable get() { return null; } }); @@ -497,9 +493,9 @@ public Throwable call() { @Test(timeout = 5000, expected = TestException.class) public void errorSupplierThrows() { - Completable c = Completable.error(new Callable() { + Completable c = Completable.error(new Supplier() { @Override - public Throwable call() { throw new TestException(); } + public Throwable get() { throw new TestException(); } }); c.blockingAwait(); @@ -571,9 +567,9 @@ public void fromFlowableSome() { @Test(timeout = 5000, expected = TestException.class) public void fromFlowableError() { - Completable c = Completable.fromPublisher(Flowable.error(new Callable() { + Completable c = Completable.fromPublisher(Flowable.error(new Supplier() { @Override - public Throwable call() { + public Throwable get() { return new TestException(); } })); @@ -604,9 +600,9 @@ public void fromObservableSome() { @Test(timeout = 5000, expected = TestException.class) public void fromObservableError() { - Completable c = Completable.fromObservable(Observable.error(new Callable() { + Completable c = Completable.fromObservable(Observable.error(new Supplier() { @Override - public Throwable call() { + public Throwable get() { return new TestException(); } })); @@ -659,9 +655,9 @@ public void fromSingleNormal() { @Test(timeout = 5000, expected = TestException.class) public void fromSingleThrows() { - Completable c = Completable.fromSingle(Single.error(new Callable() { + Completable c = Completable.fromSingle(Single.error(new Supplier() { @Override - public Throwable call() { + public Throwable get() { return new TestException(); } })); @@ -818,9 +814,9 @@ public void mergeObservableEmpty() { @Test(timeout = 5000, expected = TestException.class) public void mergeObservableError() { - Completable c = Completable.merge(Flowable.error(new Callable() { + Completable c = Completable.merge(Flowable.error(new Supplier() { @Override - public Throwable call() { + public Throwable get() { return new TestException(); } })); @@ -1038,9 +1034,9 @@ public void mergeDelayErrorObservableEmpty() { @Test(timeout = 5000, expected = TestException.class) public void mergeDelayErrorObservableError() { - Completable c = Completable.mergeDelayError(Flowable.error(new Callable() { + Completable c = Completable.mergeDelayError(Flowable.error(new Supplier() { @Override - public Throwable call() { + public Throwable get() { return new TestException(); } })); @@ -1221,9 +1217,9 @@ public void timerSchedulerNull() { public void usingNormalEager() { final AtomicInteger dispose = new AtomicInteger(); - Completable c = Completable.using(new Callable() { + Completable c = Completable.using(new Supplier() { @Override - public Integer call() { + public Integer get() { return 1; } }, new Function() { @@ -1267,9 +1263,9 @@ public void onComplete() { public void usingNormalLazy() { final AtomicInteger dispose = new AtomicInteger(); - Completable c = Completable.using(new Callable() { + Completable c = Completable.using(new Supplier() { @Override - public Integer call() { + public Integer get() { return 1; } }, new Function() { @@ -1313,9 +1309,9 @@ public void onComplete() { public void usingErrorEager() { final AtomicInteger dispose = new AtomicInteger(); - Completable c = Completable.using(new Callable() { + Completable c = Completable.using(new Supplier() { @Override - public Integer call() { + public Integer get() { return 1; } }, new Function() { @@ -1359,9 +1355,9 @@ public void onComplete() { public void usingErrorLazy() { final AtomicInteger dispose = new AtomicInteger(); - Completable c = Completable.using(new Callable() { + Completable c = Completable.using(new Supplier() { @Override - public Integer call() { + public Integer get() { return 1; } }, new Function() { @@ -1416,9 +1412,9 @@ public void accept(Object v) { } @Test(expected = NullPointerException.class) public void usingMapperNull() { - Completable.using(new Callable() { + Completable.using(new Supplier() { @Override - public Object call() { + public Object get() { return 1; } }, null, new Consumer() { @@ -1429,9 +1425,9 @@ public void accept(Object v) { } @Test(expected = NullPointerException.class) public void usingMapperReturnsNull() { - Completable c = Completable.using(new Callable() { + Completable c = Completable.using(new Supplier() { @Override - public Object call() { + public Object get() { return 1; } }, new Function() { @@ -1449,9 +1445,9 @@ public void accept(Object v) { } @Test(expected = NullPointerException.class) public void usingDisposeNull() { - Completable.using(new Callable() { + Completable.using(new Supplier() { @Override - public Object call() { + public Object get() { return 1; } }, new Function() { @@ -1464,9 +1460,9 @@ public Completable apply(Object v) { @Test(expected = TestException.class) public void usingResourceThrows() { - Completable c = Completable.using(new Callable() { + Completable c = Completable.using(new Supplier() { @Override - public Object call() { throw new TestException(); } + public Object get() { throw new TestException(); } }, new Function() { @Override @@ -1483,9 +1479,9 @@ public void accept(Object v) { } @Test(expected = TestException.class) public void usingMapperThrows() { - Completable c = Completable.using(new Callable() { + Completable c = Completable.using(new Supplier() { @Override - public Object call() { + public Object get() { return 1; } }, @@ -1502,9 +1498,9 @@ public void accept(Object v) { } @Test(expected = TestException.class) public void usingDisposerThrows() { - Completable c = Completable.using(new Callable() { + Completable c = Completable.using(new Supplier() { @Override - public Object call() { + public Object get() { return 1; } }, @@ -2886,9 +2882,9 @@ public void toObservableError() { @Test(timeout = 5000) public void toSingleSupplierNormal() { - Assert.assertEquals(1, normal.completable.toSingle(new Callable() { + Assert.assertEquals(1, normal.completable.toSingle(new Supplier() { @Override - public Object call() { + public Object get() { return 1; } }).blockingGet()); @@ -2896,9 +2892,9 @@ public Object call() { @Test(timeout = 5000, expected = TestException.class) public void toSingleSupplierError() { - error.completable.toSingle(new Callable() { + error.completable.toSingle(new Supplier() { @Override - public Object call() { + public Object get() { return 1; } }).blockingGet(); @@ -2911,9 +2907,9 @@ public void toSingleSupplierNull() { @Test(expected = NullPointerException.class) public void toSingleSupplierReturnsNull() { - normal.completable.toSingle(new Callable() { + normal.completable.toSingle(new Supplier() { @Override - public Object call() { + public Object get() { return null; } }).blockingGet(); @@ -2921,9 +2917,9 @@ public Object call() { @Test(expected = TestException.class) public void toSingleSupplierThrows() { - normal.completable.toSingle(new Callable() { + normal.completable.toSingle(new Supplier() { @Override - public Object call() { throw new TestException(); } + public Object get() { throw new TestException(); } }).blockingGet(); } @@ -3586,9 +3582,9 @@ public void accept(Integer t) { TestSubscriber ts = new TestSubscriber(); - Completable.using(new Callable() { + Completable.using(new Supplier() { @Override - public Integer call() { + public Integer get() { return 1; } }, @@ -3827,7 +3823,7 @@ public void after() { } @Test - public void testHookCreate() throws Exception { + public void testHookCreate() throws Throwable { CompletableSource subscriber = mock(CompletableSource.class); Completable create = Completable.unsafeCreate(subscriber); @@ -4062,15 +4058,15 @@ public void andThenFlowableError() { } @Test - public void usingFactoryThrows() throws Exception { + public void usingFactoryThrows() throws Throwable { @SuppressWarnings("unchecked") Consumer onDispose = mock(Consumer.class); TestSubscriber ts = new TestSubscriber(); - Completable.using(new Callable() { + Completable.using(new Supplier() { @Override - public Integer call() { + public Integer get() { return 1; } }, @@ -4099,9 +4095,9 @@ public void accept(Integer t) { TestSubscriber ts = new TestSubscriber(); - Completable.using(new Callable() { + Completable.using(new Supplier() { @Override - public Integer call() { + public Integer get() { return 1; } }, @@ -4127,15 +4123,15 @@ public Completable apply(Integer t) { } @Test - public void usingFactoryReturnsNull() throws Exception { + public void usingFactoryReturnsNull() throws Throwable { @SuppressWarnings("unchecked") Consumer onDispose = mock(Consumer.class); TestSubscriber ts = TestSubscriber.create(); - Completable.using(new Callable() { + Completable.using(new Supplier() { @Override - public Integer call() { + public Integer get() { return 1; } }, @@ -4241,7 +4237,7 @@ public void onSubscribe(Subscription s) { } @Test - public void testHookSubscribeStart() throws Exception { + public void testHookSubscribeStart() throws Throwable { TestSubscriber ts = new TestSubscriber(); Completable completable = Completable.unsafeCreate(new CompletableSource() { diff --git a/src/test/java/io/reactivex/flowable/FlowableCollectTest.java b/src/test/java/io/reactivex/flowable/FlowableCollectTest.java index f187d5b240..be419b4f91 100644 --- a/src/test/java/io/reactivex/flowable/FlowableCollectTest.java +++ b/src/test/java/io/reactivex/flowable/FlowableCollectTest.java @@ -32,9 +32,9 @@ public final class FlowableCollectTest { @Test public void testCollectToListFlowable() { Flowable> f = Flowable.just(1, 2, 3) - .collect(new Callable>() { + .collect(new Supplier>() { @Override - public List call() { + public List get() { return new ArrayList(); } }, new BiConsumer, Integer>() { @@ -64,9 +64,9 @@ public void accept(List list, Integer v) { public void testCollectToStringFlowable() { String value = Flowable.just(1, 2, 3) .collect( - new Callable() { + new Supplier() { @Override - public StringBuilder call() { + public StringBuilder get() { return new StringBuilder(); } }, @@ -86,10 +86,10 @@ public void accept(StringBuilder sb, Integer v) { @Test public void testFactoryFailureResultsInErrorEmissionFlowable() { final RuntimeException e = new RuntimeException(); - Flowable.just(1).collect(new Callable>() { + Flowable.just(1).collect(new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { throw e; } }, new BiConsumer, Integer>() { @@ -114,7 +114,7 @@ public void testCollectorFailureDoesNotResultInTwoErrorEmissionsFlowable() { final RuntimeException e2 = new RuntimeException(); Burst.items(1).error(e2) // - .collect(callableListCreator(), biConsumerThrows(e1)) + .collect(supplierListCreator(), biConsumerThrows(e1)) .toFlowable() .test() // .assertError(e1) // @@ -131,7 +131,7 @@ public void testCollectorFailureDoesNotResultInTwoErrorEmissionsFlowable() { public void testCollectorFailureDoesNotResultInErrorAndCompletedEmissionsFlowable() { final RuntimeException e = new RuntimeException(); Burst.item(1).create() // - .collect(callableListCreator(), biConsumerThrows(e)) // + .collect(supplierListCreator(), biConsumerThrows(e)) // .toFlowable() .test() // .assertError(e) // @@ -157,7 +157,7 @@ public void accept(Object o, Integer t) { } }; Burst.items(1, 2).create() // - .collect(callableListCreator(), throwOnFirstOnly)// + .collect(supplierListCreator(), throwOnFirstOnly)// .toFlowable() .test() // .assertError(e) // @@ -184,9 +184,9 @@ public void accept(HashSet s, Integer v) throws Exception { @Test public void testCollectToList() { Single> o = Flowable.just(1, 2, 3) - .collect(new Callable>() { + .collect(new Supplier>() { @Override - public List call() { + public List get() { return new ArrayList(); } }, new BiConsumer, Integer>() { @@ -216,9 +216,9 @@ public void accept(List list, Integer v) { public void testCollectToString() { String value = Flowable.just(1, 2, 3) .collect( - new Callable() { + new Supplier() { @Override - public StringBuilder call() { + public StringBuilder get() { return new StringBuilder(); } }, @@ -238,10 +238,10 @@ public void accept(StringBuilder sb, Integer v) { @Test public void testFactoryFailureResultsInErrorEmission() { final RuntimeException e = new RuntimeException(); - Flowable.just(1).collect(new Callable>() { + Flowable.just(1).collect(new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { throw e; } }, new BiConsumer, Integer>() { @@ -266,7 +266,7 @@ public void testCollectorFailureDoesNotResultInTwoErrorEmissions() { final RuntimeException e2 = new RuntimeException(); Burst.items(1).error(e2) // - .collect(callableListCreator(), biConsumerThrows(e1)) // + .collect(supplierListCreator(), biConsumerThrows(e1)) // .test() // .assertError(e1) // .assertNotComplete(); @@ -282,7 +282,7 @@ public void testCollectorFailureDoesNotResultInTwoErrorEmissions() { public void testCollectorFailureDoesNotResultInErrorAndCompletedEmissions() { final RuntimeException e = new RuntimeException(); Burst.item(1).create() // - .collect(callableListCreator(), biConsumerThrows(e)) // + .collect(supplierListCreator(), biConsumerThrows(e)) // .test() // .assertError(e) // .assertNotComplete(); @@ -307,7 +307,7 @@ public void accept(Object o, Integer t) { } }; Burst.items(1, 2).create() // - .collect(callableListCreator(), throwOnFirstOnly)// + .collect(supplierListCreator(), throwOnFirstOnly)// .test() // .assertError(e) // .assertNoValues() // @@ -332,7 +332,7 @@ public void accept(HashSet s, Integer v) throws Exception { @Test public void dispose() { TestHelper.checkDisposed(Flowable.just(1, 2) - .collect(Functions.justCallable(new ArrayList()), new BiConsumer, Integer>() { + .collect(Functions.justSupplier(new ArrayList()), new BiConsumer, Integer>() { @Override public void accept(ArrayList a, Integer b) throws Exception { a.add(b); @@ -340,7 +340,7 @@ public void accept(ArrayList a, Integer b) throws Exception { })); TestHelper.checkDisposed(Flowable.just(1, 2) - .collect(Functions.justCallable(new ArrayList()), new BiConsumer, Integer>() { + .collect(Functions.justSupplier(new ArrayList()), new BiConsumer, Integer>() { @Override public void accept(ArrayList a, Integer b) throws Exception { a.add(b); @@ -353,7 +353,7 @@ public void doubleOnSubscribe() { TestHelper.checkDoubleOnSubscribeFlowable(new Function, Flowable>>() { @Override public Flowable> apply(Flowable f) throws Exception { - return f.collect(Functions.justCallable(new ArrayList()), + return f.collect(Functions.justSupplier(new ArrayList()), new BiConsumer, Integer>() { @Override public void accept(ArrayList a, Integer b) throws Exception { @@ -365,7 +365,7 @@ public void accept(ArrayList a, Integer b) throws Exception { TestHelper.checkDoubleOnSubscribeFlowableToSingle(new Function, Single>>() { @Override public Single> apply(Flowable f) throws Exception { - return f.collect(Functions.justCallable(new ArrayList()), + return f.collect(Functions.justSupplier(new ArrayList()), new BiConsumer, Integer>() { @Override public void accept(ArrayList a, Integer b) throws Exception { diff --git a/src/test/java/io/reactivex/flowable/FlowableMergeTests.java b/src/test/java/io/reactivex/flowable/FlowableMergeTests.java index 5c96bcf096..f2cf4f8ac4 100644 --- a/src/test/java/io/reactivex/flowable/FlowableMergeTests.java +++ b/src/test/java/io/reactivex/flowable/FlowableMergeTests.java @@ -16,13 +16,13 @@ import static org.junit.Assert.*; import java.util.List; -import java.util.concurrent.Callable; import org.junit.Test; import org.reactivestreams.Publisher; import io.reactivex.Flowable; import io.reactivex.flowable.FlowableCovarianceTest.*; +import io.reactivex.functions.Supplier; public class FlowableMergeTests { @@ -76,9 +76,9 @@ public void testMergeCovariance3() { @Test public void testMergeCovariance4() { - Flowable f1 = Flowable.defer(new Callable>() { + Flowable f1 = Flowable.defer(new Supplier>() { @Override - public Publisher call() { + public Publisher get() { return Flowable.just( new HorrorMovie(), new Movie() diff --git a/src/test/java/io/reactivex/flowable/FlowableNullTests.java b/src/test/java/io/reactivex/flowable/FlowableNullTests.java index a9acc4f061..14e18460a8 100644 --- a/src/test/java/io/reactivex/flowable/FlowableNullTests.java +++ b/src/test/java/io/reactivex/flowable/FlowableNullTests.java @@ -13,11 +13,12 @@ package io.reactivex.flowable; +import static org.junit.Assert.*; + import java.lang.reflect.*; import java.util.*; import java.util.concurrent.*; -import static org.junit.Assert.*; import org.junit.*; import org.reactivestreams.*; @@ -215,9 +216,9 @@ public void deferFunctionNull() { @Test(expected = NullPointerException.class) public void deferFunctionReturnsNull() { - Flowable.defer(new Callable>() { + Flowable.defer(new Supplier>() { @Override - public Publisher call() { + public Publisher get() { return null; } }).blockingLast(); @@ -225,14 +226,14 @@ public Publisher call() { @Test(expected = NullPointerException.class) public void errorFunctionNull() { - Flowable.error((Callable)null); + Flowable.error((Supplier)null); } @Test(expected = NullPointerException.class) public void errorFunctionReturnsNull() { - Flowable.error(new Callable() { + Flowable.error(new Supplier() { @Override - public Throwable call() { + public Throwable get() { return null; } }).blockingSubscribe(); @@ -375,9 +376,9 @@ public Object apply(Object s, Emitter o) { @Test(expected = NullPointerException.class) public void generateStateConsumerNull() { - Flowable.generate(new Callable() { + Flowable.generate(new Supplier() { @Override - public Integer call() { + public Integer get() { return 1; } }, (BiConsumer>)null); @@ -391,9 +392,9 @@ public void accept(Integer s, Emitter o) { o.onComplete(); } }; - Flowable.generate(new Callable() { + Flowable.generate(new Supplier() { @Override - public Integer call() { + public Integer get() { return null; } }, generator).blockingSubscribe(); @@ -401,9 +402,9 @@ public Integer call() { @Test public void generateFunctionStateNullAllowed() { - Flowable.generate(new Callable() { + Flowable.generate(new Supplier() { @Override - public Object call() { + public Object get() { return null; } }, new BiFunction, Object>() { @@ -422,9 +423,9 @@ public void accept(Integer s, Emitter o) { o.onNext(1); } }; - Flowable.generate(new Callable() { + Flowable.generate(new Supplier() { @Override - public Integer call() { + public Integer get() { return 1; } }, generator, null); @@ -432,9 +433,9 @@ public Integer call() { @Test(expected = NullPointerException.class) public void generateFunctionDisposeNull() { - Flowable.generate(new Callable() { + Flowable.generate(new Supplier() { @Override - public Object call() { + public Object get() { return 1; } }, new BiFunction, Object>() { @@ -607,9 +608,9 @@ public Publisher apply(Object d) { @Test(expected = NullPointerException.class) public void usingFlowableSupplierNull() { - Flowable.using(new Callable() { + Flowable.using(new Supplier() { @Override - public Object call() { + public Object get() { return 1; } }, null, Functions.emptyConsumer()); @@ -617,9 +618,9 @@ public Object call() { @Test(expected = NullPointerException.class) public void usingFlowableSupplierReturnsNull() { - Flowable.using(new Callable() { + Flowable.using(new Supplier() { @Override - public Object call() { + public Object get() { return 1; } }, new Function>() { @@ -632,9 +633,9 @@ public Publisher apply(Object d) { @Test(expected = NullPointerException.class) public void usingDisposeNull() { - Flowable.using(new Callable() { + Flowable.using(new Supplier() { @Override - public Object call() { + public Object get() { return 1; } }, new Function>() { @@ -775,14 +776,14 @@ public void anyPredicateNull() { @Test(expected = NullPointerException.class) public void bufferSupplierNull() { - just1.buffer(1, 1, (Callable>)null); + just1.buffer(1, 1, (Supplier>)null); } @Test(expected = NullPointerException.class) public void bufferSupplierReturnsNull() { - just1.buffer(1, 1, new Callable>() { + just1.buffer(1, 1, new Supplier>() { @Override - public Collection call() { + public Collection get() { return null; } }).blockingSubscribe(); @@ -805,9 +806,9 @@ public void bufferTimedSupplierNull() { @Test(expected = NullPointerException.class) public void bufferTimedSupplierReturnsNull() { - just1.buffer(1L, 1L, TimeUnit.SECONDS, Schedulers.single(), new Callable>() { + just1.buffer(1L, 1L, TimeUnit.SECONDS, Schedulers.single(), new Supplier>() { @Override - public Collection call() { + public Collection get() { return null; } }).blockingSubscribe(); @@ -845,14 +846,14 @@ public void bufferBoundaryNull() { @Test(expected = NullPointerException.class) public void bufferBoundarySupplierNull() { - just1.buffer(just1, (Callable>)null); + just1.buffer(just1, (Supplier>)null); } @Test(expected = NullPointerException.class) public void bufferBoundarySupplierReturnsNull() { - just1.buffer(just1, new Callable>() { + just1.buffer(just1, new Supplier>() { @Override - public Collection call() { + public Collection get() { return null; } }).blockingSubscribe(); @@ -860,14 +861,14 @@ public Collection call() { @Test(expected = NullPointerException.class) public void bufferBoundarySupplier2Null() { - just1.buffer((Callable>)null); + just1.buffer((Supplier>)null); } @Test(expected = NullPointerException.class) public void bufferBoundarySupplier2ReturnsNull() { - just1.buffer(new Callable>() { + just1.buffer(new Supplier>() { @Override - public Publisher call() { + public Publisher get() { return null; } }).blockingSubscribe(); @@ -875,9 +876,9 @@ public Publisher call() { @Test(expected = NullPointerException.class) public void bufferBoundarySupplier2SupplierNull() { - just1.buffer(new Callable>() { + just1.buffer(new Supplier>() { @Override - public Flowable call() { + public Flowable get() { return just1; } }, null); @@ -885,14 +886,14 @@ public Flowable call() { @Test(expected = NullPointerException.class) public void bufferBoundarySupplier2SupplierReturnsNull() { - just1.buffer(new Callable>() { + just1.buffer(new Supplier>() { @Override - public Flowable call() { + public Flowable get() { return just1; } - }, new Callable>() { + }, new Supplier>() { @Override - public Collection call() { + public Collection get() { return null; } }).blockingSubscribe(); @@ -905,7 +906,7 @@ public void castNull() { @Test(expected = NullPointerException.class) public void collectInitialSupplierNull() { - just1.collect((Callable)null, new BiConsumer() { + just1.collect((Supplier)null, new BiConsumer() { @Override public void accept(Integer a, Integer b) { } }); @@ -913,9 +914,9 @@ public void accept(Integer a, Integer b) { } @Test(expected = NullPointerException.class) public void collectInitialSupplierReturnsNull() { - just1.collect(new Callable() { + just1.collect(new Supplier() { @Override - public Object call() { + public Object get() { return null; } }, new BiConsumer() { @@ -926,9 +927,9 @@ public void accept(Object a, Integer b) { } @Test(expected = NullPointerException.class) public void collectInitialCollectorNull() { - just1.collect(new Callable() { + just1.collect(new Supplier() { @Override - public Object call() { + public Object get() { return 1; } }, null); @@ -1139,9 +1140,9 @@ public void distinctSupplierReturnsNull() { public Object apply(Integer v) { return v; } - }, new Callable>() { + }, new Supplier>() { @Override - public Collection call() { + public Collection get() { return null; } }).blockingSubscribe(); @@ -1297,9 +1298,9 @@ public void flatMapNotificationOnNextNull() { public Publisher apply(Throwable e) { return just1; } - }, new Callable>() { + }, new Supplier>() { @Override - public Publisher call() { + public Publisher get() { return just1; } }); @@ -1317,9 +1318,9 @@ public Publisher apply(Integer v) { public Publisher apply(Throwable e) { return just1; } - }, new Callable>() { + }, new Supplier>() { @Override - public Publisher call() { + public Publisher get() { return just1; } }).blockingSubscribe(); @@ -1332,9 +1333,9 @@ public void flatMapNotificationOnErrorNull() { public Publisher apply(Integer v) { return just1; } - }, null, new Callable>() { + }, null, new Supplier>() { @Override - public Publisher call() { + public Publisher get() { return just1; } }); @@ -1353,9 +1354,9 @@ public Publisher apply(Object v) { public Publisher apply(Throwable e) { return null; } - }, new Callable>() { + }, new Supplier>() { @Override - public Publisher call() { + public Publisher get() { return just1; } }).blockingSubscribe(); @@ -1388,9 +1389,9 @@ public Publisher apply(Integer v) { public Publisher apply(Throwable e) { return just1; } - }, new Callable>() { + }, new Supplier>() { @Override - public Publisher call() { + public Publisher get() { return null; } }).blockingSubscribe(); @@ -1771,9 +1772,9 @@ public Object apply(Object a, Integer b) { @Test(expected = NullPointerException.class) public void reduceWithSeedReturnsNull() { - just1.reduceWith(new Callable() { + just1.reduceWith(new Supplier() { @Override - public Object call() { + public Object get() { return null; } }, new BiFunction() { @@ -2026,9 +2027,9 @@ public Object apply(Object a, Integer b) { @Test(expected = NullPointerException.class) public void scanSeedSupplierReturnsNull() { - just1.scanWith(new Callable() { + just1.scanWith(new Supplier() { @Override - public Object call() { + public Object get() { return null; } }, new BiFunction() { @@ -2041,9 +2042,9 @@ public Object apply(Object a, Integer b) { @Test(expected = NullPointerException.class) public void scanSeedSupplierFunctionNull() { - just1.scanWith(new Callable() { + just1.scanWith(new Supplier() { @Override - public Object call() { + public Object get() { return 1; } }, null); @@ -2051,9 +2052,9 @@ public Object call() { @Test(expected = NullPointerException.class) public void scanSeedSupplierFunctionReturnsNull() { - just1.scanWith(new Callable() { + just1.scanWith(new Supplier() { @Override - public Object call() { + public Object get() { return 1; } }, new BiFunction() { @@ -2371,9 +2372,9 @@ public void toListNull() { @Test(expected = NullPointerException.class) public void toListSupplierReturnsNull() { - just1.toList(new Callable>() { + just1.toList(new Supplier>() { @Override - public Collection call() { + public Collection get() { return null; } }).toFlowable().blockingSubscribe(); @@ -2381,9 +2382,9 @@ public Collection call() { @Test(expected = NullPointerException.class) public void toListSupplierReturnsNullSingle() { - just1.toList(new Callable>() { + just1.toList(new Supplier>() { @Override - public Collection call() { + public Collection get() { return null; } }).blockingGet(); @@ -2451,9 +2452,9 @@ public Object apply(Integer v) { public Object apply(Integer v) { return v; } - }, new Callable>() { + }, new Supplier>() { @Override - public Map call() { + public Map get() { return null; } }).blockingGet(); @@ -2516,9 +2517,9 @@ public Object apply(Integer v) { public Object apply(Integer v) { return v; } - }, new Callable>>() { + }, new Supplier>>() { @Override - public Map> call() { + public Map> get() { return null; } }).blockingGet(); @@ -2536,9 +2537,9 @@ public Integer apply(Integer v) { public Integer apply(Integer v) { return v; } - }, new Callable>>() { + }, new Supplier>>() { @Override - public Map> call() { + public Map> get() { return new HashMap>(); } }, null); @@ -2556,9 +2557,9 @@ public Integer apply(Integer v) { public Integer apply(Integer v) { return v; } - }, new Callable>>() { + }, new Supplier>>() { @Override - public Map> call() { + public Map> get() { return new HashMap>(); } }, new Function>() { @@ -2626,14 +2627,14 @@ public Publisher apply(Integer v) { @Test(expected = NullPointerException.class) public void windowBoundarySupplierNull() { - just1.window((Callable>)null); + just1.window((Supplier>)null); } @Test(expected = NullPointerException.class) public void windowBoundarySupplierReturnsNull() { - just1.window(new Callable>() { + just1.window(new Supplier>() { @Override - public Publisher call() { + public Publisher get() { return null; } }).blockingSubscribe(); diff --git a/src/test/java/io/reactivex/flowable/FlowableTests.java b/src/test/java/io/reactivex/flowable/FlowableTests.java index fa8026da6c..430fe50baf 100644 --- a/src/test/java/io/reactivex/flowable/FlowableTests.java +++ b/src/test/java/io/reactivex/flowable/FlowableTests.java @@ -137,9 +137,9 @@ public void testCountZeroItemsFlowable() { @Test public void testCountErrorFlowable() { - Flowable f = Flowable.error(new Callable() { + Flowable f = Flowable.error(new Supplier() { @Override - public Throwable call() { + public Throwable get() { return new RuntimeException(); } }); @@ -172,9 +172,9 @@ public void testCountZeroItems() { @Test public void testCountError() { - Flowable f = Flowable.error(new Callable() { + Flowable f = Flowable.error(new Supplier() { @Override - public Throwable call() { + public Throwable get() { return new RuntimeException(); } }); @@ -459,9 +459,9 @@ public void testCustomObservableWithErrorInObservableSynchronous() { final AtomicInteger count = new AtomicInteger(); final AtomicReference error = new AtomicReference(); // FIXME custom built??? - Flowable.just("1", "2").concatWith(Flowable.error(new Callable() { + Flowable.just("1", "2").concatWith(Flowable.error(new Supplier() { @Override - public Throwable call() { + public Throwable get() { return new NumberFormatException(); } })) diff --git a/src/test/java/io/reactivex/internal/functions/FunctionsTest.java b/src/test/java/io/reactivex/internal/functions/FunctionsTest.java index c5dff9e160..e2a473fa44 100644 --- a/src/test/java/io/reactivex/internal/functions/FunctionsTest.java +++ b/src/test/java/io/reactivex/internal/functions/FunctionsTest.java @@ -72,7 +72,7 @@ public void naturalComparatorEnum() { } @Test - public void booleanSupplierPredicateReverse() throws Exception { + public void booleanSupplierPredicateReverse() throws Throwable { BooleanSupplier s = new BooleanSupplier() { @Override public boolean getAsBoolean() throws Exception { @@ -93,7 +93,7 @@ public boolean getAsBoolean() throws Exception { } @Test(expected = IllegalArgumentException.class) - public void toFunction2() throws Exception { + public void toFunction2() throws Throwable { Functions.toFunction(new BiFunction() { @Override public Integer apply(Integer t1, Integer t2) throws Exception { @@ -103,7 +103,7 @@ public Integer apply(Integer t1, Integer t2) throws Exception { } @Test(expected = IllegalArgumentException.class) - public void toFunction3() throws Exception { + public void toFunction3() throws Throwable { Functions.toFunction(new Function3() { @Override public Integer apply(Integer t1, Integer t2, Integer t3) throws Exception { @@ -113,7 +113,7 @@ public Integer apply(Integer t1, Integer t2, Integer t3) throws Exception { } @Test(expected = IllegalArgumentException.class) - public void toFunction4() throws Exception { + public void toFunction4() throws Throwable { Functions.toFunction(new Function4() { @Override public Integer apply(Integer t1, Integer t2, Integer t3, Integer t4) throws Exception { @@ -123,7 +123,7 @@ public Integer apply(Integer t1, Integer t2, Integer t3, Integer t4) throws Exce } @Test(expected = IllegalArgumentException.class) - public void toFunction5() throws Exception { + public void toFunction5() throws Throwable { Functions.toFunction(new Function5() { @Override public Integer apply(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5) throws Exception { @@ -133,7 +133,7 @@ public Integer apply(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5) } @Test(expected = IllegalArgumentException.class) - public void toFunction6() throws Exception { + public void toFunction6() throws Throwable { Functions.toFunction(new Function6() { @Override public Integer apply(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6) throws Exception { @@ -143,7 +143,7 @@ public Integer apply(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, } @Test(expected = IllegalArgumentException.class) - public void toFunction7() throws Exception { + public void toFunction7() throws Throwable { Functions.toFunction(new Function7() { @Override public Integer apply(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6, Integer t7) throws Exception { @@ -153,7 +153,7 @@ public Integer apply(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, } @Test(expected = IllegalArgumentException.class) - public void toFunction8() throws Exception { + public void toFunction8() throws Throwable { Functions.toFunction(new Function8() { @Override public Integer apply(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6, Integer t7, Integer t8) throws Exception { @@ -163,7 +163,7 @@ public Integer apply(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, } @Test(expected = IllegalArgumentException.class) - public void toFunction9() throws Exception { + public void toFunction9() throws Throwable { Functions.toFunction(new Function9() { @Override public Integer apply(Integer t1, Integer t2, Integer t3, Integer t4, Integer t5, Integer t6, Integer t7, Integer t8, Integer t9) throws Exception { @@ -249,7 +249,7 @@ public void emptyConsumerToString() { } @Test - public void errorConsumerEmpty() throws Exception { + public void errorConsumerEmpty() throws Throwable { List errors = TestHelper.trackPluginErrors(); try { Functions.ERROR_CONSUMER.accept(new TestException()); diff --git a/src/test/java/io/reactivex/internal/operators/completable/CompletableUsingTest.java b/src/test/java/io/reactivex/internal/operators/completable/CompletableUsingTest.java index 5d1a4cfc42..af53d63301 100644 --- a/src/test/java/io/reactivex/internal/operators/completable/CompletableUsingTest.java +++ b/src/test/java/io/reactivex/internal/operators/completable/CompletableUsingTest.java @@ -16,7 +16,6 @@ import static org.junit.Assert.*; import java.util.List; -import java.util.concurrent.Callable; import org.junit.Test; @@ -34,9 +33,9 @@ public class CompletableUsingTest { @Test public void resourceSupplierThrows() { - Completable.using(new Callable() { + Completable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { throw new TestException(); } }, new Function() { @@ -57,9 +56,9 @@ public void accept(Object d) throws Exception { @Test public void errorEager() { - Completable.using(new Callable() { + Completable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function() { @@ -80,9 +79,9 @@ public void accept(Object d) throws Exception { @Test public void emptyEager() { - Completable.using(new Callable() { + Completable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function() { @@ -103,9 +102,9 @@ public void accept(Object d) throws Exception { @Test public void errorNonEager() { - Completable.using(new Callable() { + Completable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function() { @@ -126,9 +125,9 @@ public void accept(Object d) throws Exception { @Test public void emptyNonEager() { - Completable.using(new Callable() { + Completable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function() { @@ -149,9 +148,9 @@ public void accept(Object d) throws Exception { @Test public void supplierCrashEager() { - Completable.using(new Callable() { + Completable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function() { @@ -172,9 +171,9 @@ public void accept(Object d) throws Exception { @Test public void supplierCrashNonEager() { - Completable.using(new Callable() { + Completable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function() { @@ -194,9 +193,9 @@ public void accept(Object d) throws Exception { @Test public void supplierAndDisposerCrashEager() { - TestObserver to = Completable.using(new Callable() { + TestObserver to = Completable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function() { @@ -223,9 +222,9 @@ public void accept(Object d) throws Exception { public void supplierAndDisposerCrashNonEager() { List errors = TestHelper.trackPluginErrors(); try { - Completable.using(new Callable() { + Completable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function() { @@ -252,9 +251,9 @@ public void accept(Object d) throws Exception { public void dispose() { final int[] call = {0 }; - TestObserver to = Completable.using(new Callable() { + TestObserver to = Completable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function() { @@ -279,9 +278,9 @@ public void accept(Object d) throws Exception { public void disposeCrashes() { List errors = TestHelper.trackPluginErrors(); try { - TestObserver to = Completable.using(new Callable() { + TestObserver to = Completable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function() { @@ -307,9 +306,9 @@ public void accept(Object d) throws Exception { @Test public void isDisposed() { - TestHelper.checkDisposed(Completable.using(new Callable() { + TestHelper.checkDisposed(Completable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function() { @@ -327,9 +326,9 @@ public void accept(Object d) throws Exception { @Test public void justDisposerCrashes() { - Completable.using(new Callable() { + Completable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function() { @@ -349,9 +348,9 @@ public void accept(Object d) throws Exception { @Test public void emptyDisposerCrashes() { - Completable.using(new Callable() { + Completable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function() { @@ -371,9 +370,9 @@ public void accept(Object d) throws Exception { @Test public void errorDisposerCrash() { - TestObserver to = Completable.using(new Callable() { + TestObserver to = Completable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function() { @@ -400,9 +399,9 @@ public void accept(Object d) throws Exception { public void doubleOnSubscribe() { List errors = TestHelper.trackPluginErrors(); try { - Completable.using(new Callable() { + Completable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function() { @@ -443,9 +442,9 @@ public void successDisposeRace() { final PublishSubject ps = PublishSubject.create(); - final TestObserver to = Completable.using(new Callable() { + final TestObserver to = Completable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function() { @@ -488,9 +487,9 @@ public void errorDisposeRace() { final PublishSubject ps = PublishSubject.create(); - final TestObserver to = Completable.using(new Callable() { + final TestObserver to = Completable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function() { @@ -534,9 +533,9 @@ public void emptyDisposeRace() { final PublishSubject ps = PublishSubject.create(); - final TestObserver to = Completable.using(new Callable() { + final TestObserver to = Completable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function() { diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableBufferTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableBufferTest.java index e79130ff41..920958fb91 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableBufferTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableBufferTest.java @@ -253,9 +253,9 @@ public void subscribe(Subscriber subscriber) { } }); - Callable> closer = new Callable>() { + Supplier> closer = new Supplier>() { @Override - public Flowable call() { + public Flowable get() { return Flowable.unsafeCreate(new Publisher() { @Override public void subscribe(Subscriber subscriber) { @@ -1301,9 +1301,9 @@ static HashSet set(Integer... values) { @Test public void bufferIntoCustomCollection() { Flowable.just(1, 1, 2, 2, 3, 3, 4, 4) - .buffer(3, new Callable>() { + .buffer(3, new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { return new HashSet(); } }) @@ -1315,9 +1315,9 @@ public Collection call() throws Exception { @Test public void bufferSkipIntoCustomCollection() { Flowable.just(1, 1, 2, 2, 3, 3, 4, 4) - .buffer(3, 3, new Callable>() { + .buffer(3, 3, new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { return new HashSet(); } }) @@ -1337,9 +1337,9 @@ public void bufferTimeSkipDefault() { @SuppressWarnings("unchecked") public void boundaryBufferSupplierThrows() { Flowable.never() - .buffer(Functions.justCallable(Flowable.never()), new Callable>() { + .buffer(Functions.justSupplier(Flowable.never()), new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { throw new TestException(); } }) @@ -1351,14 +1351,14 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void boundaryBoundarySupplierThrows() { Flowable.never() - .buffer(new Callable>() { + .buffer(new Supplier>() { @Override - public Publisher call() throws Exception { + public Publisher get() throws Exception { throw new TestException(); } - }, new Callable>() { + }, new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { return new ArrayList(); } }) @@ -1370,10 +1370,10 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void boundaryBufferSupplierThrows2() { Flowable.never() - .buffer(Functions.justCallable(Flowable.timer(1, TimeUnit.MILLISECONDS)), new Callable>() { + .buffer(Functions.justSupplier(Flowable.timer(1, TimeUnit.MILLISECONDS)), new Supplier>() { int count; @Override - public Collection call() throws Exception { + public Collection get() throws Exception { if (count++ == 1) { throw new TestException(); } else { @@ -1390,10 +1390,10 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void boundaryBufferSupplierReturnsNull() { Flowable.never() - .buffer(Functions.justCallable(Flowable.timer(1, TimeUnit.MILLISECONDS)), new Callable>() { + .buffer(Functions.justSupplier(Flowable.timer(1, TimeUnit.MILLISECONDS)), new Supplier>() { int count; @Override - public Collection call() throws Exception { + public Collection get() throws Exception { if (count++ == 1) { return null; } else { @@ -1410,18 +1410,18 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void boundaryBoundarySupplierThrows2() { Flowable.never() - .buffer(new Callable>() { + .buffer(new Supplier>() { int count; @Override - public Publisher call() throws Exception { + public Publisher get() throws Exception { if (count++ == 1) { throw new TestException(); } return Flowable.timer(1, TimeUnit.MILLISECONDS); } - }, new Callable>() { + }, new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { return new ArrayList(); } }) @@ -1435,9 +1435,9 @@ public void boundaryCancel() { PublishProcessor pp = PublishProcessor.create(); TestSubscriber> ts = pp - .buffer(Functions.justCallable(Flowable.never()), new Callable>() { + .buffer(Functions.justSupplier(Flowable.never()), new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { return new ArrayList(); } }) @@ -1454,18 +1454,18 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void boundaryBoundarySupplierReturnsNull() { Flowable.never() - .buffer(new Callable>() { + .buffer(new Supplier>() { int count; @Override - public Publisher call() throws Exception { + public Publisher get() throws Exception { if (count++ == 1) { return null; } return Flowable.timer(1, TimeUnit.MILLISECONDS); } - }, new Callable>() { + }, new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { return new ArrayList(); } }) @@ -1478,18 +1478,18 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void boundaryBoundarySupplierReturnsNull2() { Flowable.never() - .buffer(new Callable>() { + .buffer(new Supplier>() { int count; @Override - public Publisher call() throws Exception { + public Publisher get() throws Exception { if (count++ == 1) { return null; } return Flowable.empty(); } - }, new Callable>() { + }, new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { return new ArrayList(); } }) @@ -1504,9 +1504,9 @@ public void boundaryMainError() { PublishProcessor pp = PublishProcessor.create(); TestSubscriber> ts = pp - .buffer(Functions.justCallable(Flowable.never()), new Callable>() { + .buffer(Functions.justSupplier(Flowable.never()), new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { return new ArrayList(); } }) @@ -1523,9 +1523,9 @@ public void boundaryBoundaryError() { PublishProcessor pp = PublishProcessor.create(); TestSubscriber> ts = pp - .buffer(Functions.justCallable(Flowable.error(new TestException())), new Callable>() { + .buffer(Functions.justSupplier(Flowable.error(new TestException())), new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { return new ArrayList(); } }) @@ -1558,10 +1558,10 @@ public void dispose() { @SuppressWarnings("unchecked") public void supplierReturnsNull() { Flowable.never() - .buffer(1, TimeUnit.MILLISECONDS, Schedulers.single(), Integer.MAX_VALUE, new Callable>() { + .buffer(1, TimeUnit.MILLISECONDS, Schedulers.single(), Integer.MAX_VALUE, new Supplier>() { int count; @Override - public Collection call() throws Exception { + public Collection get() throws Exception { if (count++ == 1) { return null; } else { @@ -1578,10 +1578,10 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void supplierReturnsNull2() { Flowable.never() - .buffer(1, TimeUnit.MILLISECONDS, Schedulers.single(), 10, new Callable>() { + .buffer(1, TimeUnit.MILLISECONDS, Schedulers.single(), 10, new Supplier>() { int count; @Override - public Collection call() throws Exception { + public Collection get() throws Exception { if (count++ == 1) { return null; } else { @@ -1598,10 +1598,10 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void supplierReturnsNull3() { Flowable.never() - .buffer(2, 1, TimeUnit.MILLISECONDS, Schedulers.single(), new Callable>() { + .buffer(2, 1, TimeUnit.MILLISECONDS, Schedulers.single(), new Supplier>() { int count; @Override - public Collection call() throws Exception { + public Collection get() throws Exception { if (count++ == 1) { return null; } else { @@ -1618,9 +1618,9 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void supplierThrows() { Flowable.just(1) - .buffer(1, TimeUnit.SECONDS, Schedulers.single(), Integer.MAX_VALUE, new Callable>() { + .buffer(1, TimeUnit.SECONDS, Schedulers.single(), Integer.MAX_VALUE, new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { throw new TestException(); } }, false) @@ -1632,9 +1632,9 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void supplierThrows2() { Flowable.just(1) - .buffer(1, TimeUnit.SECONDS, Schedulers.single(), 10, new Callable>() { + .buffer(1, TimeUnit.SECONDS, Schedulers.single(), 10, new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { throw new TestException(); } }, false) @@ -1646,9 +1646,9 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void supplierThrows3() { Flowable.just(1) - .buffer(2, 1, TimeUnit.SECONDS, Schedulers.single(), new Callable>() { + .buffer(2, 1, TimeUnit.SECONDS, Schedulers.single(), new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { throw new TestException(); } }) @@ -1660,10 +1660,10 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void supplierThrows4() { Flowable.never() - .buffer(1, TimeUnit.MILLISECONDS, Schedulers.single(), Integer.MAX_VALUE, new Callable>() { + .buffer(1, TimeUnit.MILLISECONDS, Schedulers.single(), Integer.MAX_VALUE, new Supplier>() { int count; @Override - public Collection call() throws Exception { + public Collection get() throws Exception { if (count++ == 1) { throw new TestException(); } else { @@ -1680,10 +1680,10 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void supplierThrows5() { Flowable.never() - .buffer(1, TimeUnit.MILLISECONDS, Schedulers.single(), 10, new Callable>() { + .buffer(1, TimeUnit.MILLISECONDS, Schedulers.single(), 10, new Supplier>() { int count; @Override - public Collection call() throws Exception { + public Collection get() throws Exception { if (count++ == 1) { throw new TestException(); } else { @@ -1700,10 +1700,10 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void supplierThrows6() { Flowable.never() - .buffer(2, 1, TimeUnit.MILLISECONDS, Schedulers.single(), new Callable>() { + .buffer(2, 1, TimeUnit.MILLISECONDS, Schedulers.single(), new Supplier>() { int count; @Override - public Collection call() throws Exception { + public Collection get() throws Exception { if (count++ == 1) { throw new TestException(); } else { @@ -1738,10 +1738,10 @@ public void bufferSkipError() { @Test public void bufferSupplierCrash2() { Flowable.range(1, 2) - .buffer(1, new Callable>() { + .buffer(1, new Supplier>() { int calls; @Override - public List call() throws Exception { + public List get() throws Exception { if (++calls == 2) { throw new TestException(); } @@ -1756,10 +1756,10 @@ public List call() throws Exception { @Test public void bufferSkipSupplierCrash2() { Flowable.range(1, 2) - .buffer(1, 2, new Callable>() { + .buffer(1, 2, new Supplier>() { int calls; @Override - public List call() throws Exception { + public List get() throws Exception { if (++calls == 1) { throw new TestException(); } @@ -1774,10 +1774,10 @@ public List call() throws Exception { @Test public void bufferOverlapSupplierCrash2() { Flowable.range(1, 2) - .buffer(2, 1, new Callable>() { + .buffer(2, 1, new Supplier>() { int calls; @Override - public List call() throws Exception { + public List get() throws Exception { if (++calls == 2) { throw new TestException(); } @@ -1865,10 +1865,10 @@ public void bufferTimedExactSupplierCrash() { PublishProcessor pp = PublishProcessor.create(); TestSubscriber> ts = pp - .buffer(1, TimeUnit.MILLISECONDS, scheduler, 1, new Callable>() { + .buffer(1, TimeUnit.MILLISECONDS, scheduler, 1, new Supplier>() { int calls; @Override - public List call() throws Exception { + public List get() throws Exception { if (++calls == 2) { throw new TestException(); } @@ -2469,10 +2469,10 @@ public void bufferExactBoundarySecondBufferCrash() { PublishProcessor pp = PublishProcessor.create(); PublishProcessor b = PublishProcessor.create(); - TestSubscriber> ts = pp.buffer(b, new Callable>() { + TestSubscriber> ts = pp.buffer(b, new Supplier>() { int calls; @Override - public List call() throws Exception { + public List get() throws Exception { if (++calls == 2) { throw new TestException(); } @@ -2552,7 +2552,7 @@ public void bufferBoundaryErrorTwice() { List errors = TestHelper.trackPluginErrors(); try { BehaviorProcessor.createDefault(1) - .buffer(Functions.justCallable(new Flowable() { + .buffer(Functions.justSupplier(new Flowable() { @Override protected void subscribeActual(Subscriber s) { s.onSubscribe(new BooleanSubscription()); @@ -2576,8 +2576,8 @@ public void bufferBoundarySupplierDisposed() { TestSubscriber> ts = new TestSubscriber>(); BufferBoundarySupplierSubscriber, Integer> sub = new BufferBoundarySupplierSubscriber, Integer>( - ts, Functions.justCallable((List)new ArrayList()), - Functions.justCallable(Flowable.never()) + ts, Functions.justSupplier((List)new ArrayList()), + Functions.justSupplier(Flowable.never()) ); BooleanSubscription bs = new BooleanSubscription(); @@ -2605,8 +2605,8 @@ public void bufferBoundarySupplierBufferAlreadyCleared() { TestSubscriber> ts = new TestSubscriber>(); BufferBoundarySupplierSubscriber, Integer> sub = new BufferBoundarySupplierSubscriber, Integer>( - ts, Functions.justCallable((List)new ArrayList()), - Functions.justCallable(Flowable.never()) + ts, Functions.justSupplier((List)new ArrayList()), + Functions.justSupplier(Flowable.never()) ); BooleanSubscription bs = new BooleanSubscription(); @@ -2653,7 +2653,7 @@ public void timedInternalState() { TestSubscriber> ts = new TestSubscriber>(); BufferExactUnboundedSubscriber> sub = new BufferExactUnboundedSubscriber>( - ts, Functions.justCallable((List)new ArrayList()), 1, TimeUnit.SECONDS, sch); + ts, Functions.justSupplier((List)new ArrayList()), 1, TimeUnit.SECONDS, sch); sub.onSubscribe(new BooleanSubscription()); @@ -2703,7 +2703,7 @@ public void timedSkipInternalState() { TestSubscriber> ts = new TestSubscriber>(); BufferSkipBoundedSubscriber> sub = new BufferSkipBoundedSubscriber>( - ts, Functions.justCallable((List)new ArrayList()), 1, 1, TimeUnit.SECONDS, sch.createWorker()); + ts, Functions.justSupplier((List)new ArrayList()), 1, 1, TimeUnit.SECONDS, sch.createWorker()); sub.onSubscribe(new BooleanSubscription()); @@ -2722,10 +2722,10 @@ public void timedSkipCancelWhenSecondBuffer() { final TestSubscriber> ts = new TestSubscriber>(); BufferSkipBoundedSubscriber> sub = new BufferSkipBoundedSubscriber>( - ts, new Callable>() { + ts, new Supplier>() { int calls; @Override - public List call() throws Exception { + public List get() throws Exception { if (++calls == 2) { ts.cancel(); } @@ -2748,7 +2748,7 @@ public void timedSizeBufferAlreadyCleared() { BufferExactBoundedSubscriber> sub = new BufferExactBoundedSubscriber>( - ts, Functions.justCallable((List)new ArrayList()), + ts, Functions.justSupplier((List)new ArrayList()), 1, TimeUnit.SECONDS, 1, false, sch.createWorker()) ; @@ -2773,9 +2773,9 @@ public void timedSizeBufferAlreadyCleared() { @Test public void bufferExactFailingSupplier() { Flowable.empty() - .buffer(1, TimeUnit.SECONDS, Schedulers.computation(), 10, new Callable>() { + .buffer(1, TimeUnit.SECONDS, Schedulers.computation(), 10, new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { throw new TestException(); } }, false) diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableCacheTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableCacheTest.java index 4208b18dec..328c28b374 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableCacheTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableCacheTest.java @@ -133,7 +133,7 @@ public void accept(String v) { } @Test - public void testUnsubscribeSource() throws Exception { + public void testUnsubscribeSource() throws Throwable { Action unsubscribe = mock(Action.class); Flowable f = Flowable.just(1).doOnCancel(unsubscribe).cache(); f.subscribe(); diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableDeferTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableDeferTest.java index 8d46e9c34e..2b16044e76 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableDeferTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableDeferTest.java @@ -13,15 +13,15 @@ package io.reactivex.internal.operators.flowable; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; -import java.util.concurrent.Callable; - import org.junit.Test; import org.reactivestreams.Subscriber; import io.reactivex.*; import io.reactivex.exceptions.TestException; +import io.reactivex.functions.Supplier; @SuppressWarnings("unchecked") public class FlowableDeferTest { @@ -29,11 +29,11 @@ public class FlowableDeferTest { @Test public void testDefer() throws Throwable { - Callable> factory = mock(Callable.class); + Supplier> factory = mock(Supplier.class); Flowable firstObservable = Flowable.just("one", "two"); Flowable secondObservable = Flowable.just("three", "four"); - when(factory.call()).thenReturn(firstObservable, secondObservable); + when(factory.get()).thenReturn(firstObservable, secondObservable); Flowable deferred = Flowable.defer(factory); @@ -42,7 +42,7 @@ public void testDefer() throws Throwable { Subscriber firstSubscriber = TestHelper.mockSubscriber(); deferred.subscribe(firstSubscriber); - verify(factory, times(1)).call(); + verify(factory, times(1)).get(); verify(firstSubscriber, times(1)).onNext("one"); verify(firstSubscriber, times(1)).onNext("two"); verify(firstSubscriber, times(0)).onNext("three"); @@ -52,7 +52,7 @@ public void testDefer() throws Throwable { Subscriber secondSubscriber = TestHelper.mockSubscriber(); deferred.subscribe(secondSubscriber); - verify(factory, times(2)).call(); + verify(factory, times(2)).get(); verify(secondSubscriber, times(0)).onNext("one"); verify(secondSubscriber, times(0)).onNext("two"); verify(secondSubscriber, times(1)).onNext("three"); @@ -62,10 +62,10 @@ public void testDefer() throws Throwable { } @Test - public void testDeferFunctionThrows() throws Exception { - Callable> factory = mock(Callable.class); + public void testDeferFunctionThrows() throws Throwable { + Supplier> factory = mock(Supplier.class); - when(factory.call()).thenThrow(new TestException()); + when(factory.get()).thenThrow(new TestException()); Flowable result = Flowable.defer(factory); diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableDelayTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableDelayTest.java index 401b9c62b4..47d15ed3d4 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableDelayTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableDelayTest.java @@ -396,9 +396,9 @@ public Flowable apply(Integer t1) { public void testDelayWithFlowableSubscriptionFunctionThrows() { PublishProcessor source = PublishProcessor.create(); final PublishProcessor delay = PublishProcessor.create(); - Callable> subFunc = new Callable>() { + Supplier> subFunc = new Supplier>() { @Override - public Flowable call() { + public Flowable get() { throw new TestException(); } }; @@ -430,9 +430,9 @@ public Flowable apply(Integer t1) { public void testDelayWithFlowableSubscriptionThrows() { PublishProcessor source = PublishProcessor.create(); final PublishProcessor delay = PublishProcessor.create(); - Callable> subFunc = new Callable>() { + Supplier> subFunc = new Supplier>() { @Override - public Flowable call() { + public Flowable get() { return delay; } }; @@ -490,9 +490,9 @@ public void testDelayWithFlowableSubscriptionRunCompletion() { PublishProcessor source = PublishProcessor.create(); final PublishProcessor sdelay = PublishProcessor.create(); final PublishProcessor delay = PublishProcessor.create(); - Callable> subFunc = new Callable>() { + Supplier> subFunc = new Supplier>() { @Override - public Flowable call() { + public Flowable get() { return sdelay; } }; @@ -727,10 +727,10 @@ public Integer apply(Integer t) { public void testBackpressureWithSelectorDelayAndSubscriptionDelay() { TestSubscriber ts = new TestSubscriber(); Flowable.range(1, Flowable.bufferSize() * 2) - .delay(Flowable.defer(new Callable>() { + .delay(Flowable.defer(new Supplier>() { @Override - public Flowable call() { + public Flowable get() { return Flowable.timer(500, TimeUnit.MILLISECONDS); } }), new Function>() { @@ -795,9 +795,9 @@ public void testDelaySupplierSimple() { TestSubscriber ts = new TestSubscriber(); - source.delaySubscription(Flowable.defer(new Callable>() { + source.delaySubscription(Flowable.defer(new Supplier>() { @Override - public Publisher call() { + public Publisher get() { return pp; } })).subscribe(ts); @@ -821,9 +821,9 @@ public void testDelaySupplierCompletes() { TestSubscriber ts = new TestSubscriber(); - source.delaySubscription(Flowable.defer(new Callable>() { + source.delaySubscription(Flowable.defer(new Supplier>() { @Override - public Publisher call() { + public Publisher get() { return pp; } })).subscribe(ts); @@ -848,9 +848,9 @@ public void testDelaySupplierErrors() { TestSubscriber ts = new TestSubscriber(); - source.delaySubscription(Flowable.defer(new Callable>() { + source.delaySubscription(Flowable.defer(new Supplier>() { @Override - public Publisher call() { + public Publisher get() { return pp; } })).subscribe(ts); diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableDistinctTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableDistinctTest.java index 448e963d49..a33aa6c219 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableDistinctTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableDistinctTest.java @@ -18,7 +18,6 @@ import static org.mockito.Mockito.*; import java.util.*; -import java.util.concurrent.Callable; import org.junit.*; import org.mockito.InOrder; @@ -26,7 +25,7 @@ import io.reactivex.*; import io.reactivex.exceptions.TestException; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; import io.reactivex.internal.functions.Functions; import io.reactivex.internal.fuseable.*; import io.reactivex.internal.subscriptions.BooleanSubscription; @@ -202,9 +201,9 @@ public void onComplete() { @Test public void collectionSupplierThrows() { Flowable.just(1) - .distinct(Functions.identity(), new Callable>() { + .distinct(Functions.identity(), new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { throw new TestException(); } }) @@ -215,9 +214,9 @@ public Collection call() throws Exception { @Test public void collectionSupplierIsNull() { Flowable.just(1) - .distinct(Functions.identity(), new Callable>() { + .distinct(Functions.identity(), new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { return null; } }) diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableDoAfterTerminateTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableDoAfterTerminateTest.java index c8b327fe04..b692c30b6a 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableDoAfterTerminateTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableDoAfterTerminateTest.java @@ -84,7 +84,7 @@ public void nullFinallyActionShouldBeCheckedASAP() { } @Test - public void ifFinallyActionThrowsExceptionShouldNotBeSwallowedAndActionShouldBeCalledOnce() throws Exception { + public void ifFinallyActionThrowsExceptionShouldNotBeSwallowedAndActionShouldBeCalledOnce() throws Throwable { List errors = TestHelper.trackPluginErrors(); try { Action finallyAction = Mockito.mock(Action.class); diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableFlatMapTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableFlatMapTest.java index 4c1441775b..96ccd95e44 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableFlatMapTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableFlatMapTest.java @@ -160,11 +160,11 @@ public R apply(T t1) { }; } - Callable just0(final R value) { - return new Callable() { + Supplier just0(final R value) { + return new Supplier() { @Override - public R call() { + public R get() { return value; } }; @@ -217,10 +217,10 @@ Flowable. error(new RuntimeException("Forced failure!")) verify(subscriber, never()).onError(any(Throwable.class)); } - Callable funcThrow0(R r) { - return new Callable() { + Supplier funcThrow0(R r) { + return new Supplier() { @Override - public R call() { + public R get() { throw new TestException(); } }; @@ -423,7 +423,7 @@ public void testFlatMapTransformsMaxConcurrentNormal() { Function> just = just(onNext); Function> just2 = just(onError); - Callable> just0 = just0(onComplete); + Supplier> just0 = just0(onComplete); source.flatMap(just, just2, just0, m).subscribe(ts); ts.awaitTerminalEvent(1, TimeUnit.SECONDS); diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableFlattenIterableTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableFlattenIterableTest.java index 9baf8f2ea7..f3a7cced77 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableFlattenIterableTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableFlattenIterableTest.java @@ -1057,7 +1057,7 @@ public void badRequest() { } @Test - public void fusedCurrentIteratorEmpty() throws Exception { + public void fusedCurrentIteratorEmpty() throws Throwable { TestSubscriber ts = new TestSubscriber(0); FlattenIterableSubscriber f = new FlattenIterableSubscriber(ts, Functions.justFunction(Arrays.asList(1, 2)), 128); diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableFromArrayTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableFromArrayTest.java index 2112541c29..53905fe305 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableFromArrayTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableFromArrayTest.java @@ -21,7 +21,7 @@ import io.reactivex.*; import io.reactivex.functions.Predicate; import io.reactivex.internal.functions.Functions; -import io.reactivex.internal.fuseable.ScalarCallable; +import io.reactivex.internal.fuseable.ScalarSupplier; import io.reactivex.subscribers.TestSubscriber; public class FlowableFromArrayTest { @@ -101,7 +101,7 @@ public void empty() { @Test public void just() { Flowable source = Flowable.fromArray(new Integer[] { 1 }); - Assert.assertTrue(source.getClass().toString(), source instanceof ScalarCallable); + Assert.assertTrue(source.getClass().toString(), source instanceof ScalarSupplier); } @Test diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableFromIterableTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableFromIterableTest.java index e33556cb4e..a7cc0770e7 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableFromIterableTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableFromIterableTest.java @@ -580,7 +580,7 @@ public void onSubscribe(Subscription s) { try { assertEquals(1, qs.poll().intValue()); - } catch (Exception ex) { + } catch (Throwable ex) { throw new AssertionError(ex); } diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableGenerateTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableGenerateTest.java index 73a7401588..2689e7d3dc 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableGenerateTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableGenerateTest.java @@ -16,7 +16,6 @@ import static org.junit.Assert.assertEquals; import java.util.List; -import java.util.concurrent.Callable; import org.junit.Test; @@ -31,9 +30,9 @@ public class FlowableGenerateTest { @Test public void statefulBiconsumer() { - Flowable.generate(new Callable() { + Flowable.generate(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 10; } }, new BiConsumer>() { @@ -54,9 +53,9 @@ public void accept(Object d) throws Exception { @Test public void stateSupplierThrows() { - Flowable.generate(new Callable() { + Flowable.generate(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { throw new TestException(); } }, new BiConsumer>() { @@ -71,9 +70,9 @@ public void accept(Object s, Emitter e) throws Exception { @Test public void generatorThrows() { - Flowable.generate(new Callable() { + Flowable.generate(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new BiConsumer>() { @@ -90,9 +89,9 @@ public void accept(Object s, Emitter e) throws Exception { public void disposerThrows() { List errors = TestHelper.trackPluginErrors(); try { - Flowable.generate(new Callable() { + Flowable.generate(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new BiConsumer>() { @@ -117,9 +116,9 @@ public void accept(Object d) throws Exception { @Test public void dispose() { - TestHelper.checkDisposed(Flowable.generate(new Callable() { + TestHelper.checkDisposed(Flowable.generate(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new BiConsumer>() { @@ -133,7 +132,7 @@ public void accept(Object s, Emitter e) throws Exception { @Test public void nullError() { final int[] call = { 0 }; - Flowable.generate(Functions.justCallable(1), + Flowable.generate(Functions.justSupplier(1), new BiConsumer>() { @Override public void accept(Integer s, Emitter e) throws Exception { @@ -152,9 +151,9 @@ public void accept(Integer s, Emitter e) throws Exception { @Test public void badRequest() { - TestHelper.assertBadRequestReported(Flowable.generate(new Callable() { + TestHelper.assertBadRequestReported(Flowable.generate(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new BiConsumer>() { @@ -167,9 +166,9 @@ public void accept(Object s, Emitter e) throws Exception { @Test public void rebatchAndTake() { - Flowable.generate(new Callable() { + Flowable.generate(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new BiConsumer>() { @@ -186,9 +185,9 @@ public void accept(Object s, Emitter e) throws Exception { @Test public void backpressure() { - Flowable.generate(new Callable() { + Flowable.generate(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new BiConsumer>() { @@ -207,9 +206,9 @@ public void accept(Object s, Emitter e) throws Exception { @Test public void requestRace() { - Flowable source = Flowable.generate(new Callable() { + Flowable source = Flowable.generate(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new BiConsumer>() { diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableGroupByTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableGroupByTest.java index 97a0a5ca23..af33f7d357 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableGroupByTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableGroupByTest.java @@ -1970,7 +1970,7 @@ public Map apply(final Consumer action) throws Exceptio public void onRemoval(RemovalNotification notification) { try { action.accept(notification.getValue()); - } catch (Exception ex) { + } catch (Throwable ex) { throw new RuntimeException(ex); } } @@ -2123,7 +2123,7 @@ public V put(K key, V value) { if (v != null) { try { evictedListener.accept(v); - } catch (Exception e) { + } catch (Throwable e) { throw new RuntimeException(e); } } @@ -2178,7 +2178,7 @@ public Map apply(final Consumer notify) throws Exceptio public void onRemoval(RemovalNotification notification) { try { notify.accept(notification.getValue()); - } catch (Exception e) { + } catch (Throwable e) { throw new RuntimeException(e); } }}) @@ -2199,7 +2199,7 @@ public Map apply(final Consumer notify) throws Exceptio public void accept(Object object) { try { notify.accept(object); - } catch (Exception e) { + } catch (Throwable e) { throw new RuntimeException(e); } }}); diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableGroupJoinTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableGroupJoinTest.java index b9e1b4f995..da24ccbc0a 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableGroupJoinTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableGroupJoinTest.java @@ -68,7 +68,7 @@ public Flowable apply(T t1) { public Flowable apply(final Integer leftValue, Flowable rightValues) { return rightValues.map(new Function() { @Override - public Integer apply(Integer rightValue) throws Exception { + public Integer apply(Integer rightValue) throws Throwable { return add.apply(leftValue, rightValue); } }); diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableIgnoreElementsTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableIgnoreElementsTest.java index 1f6c9e23a5..4d2915fac5 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableIgnoreElementsTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableIgnoreElementsTest.java @@ -273,7 +273,7 @@ public void onSubscribe(Subscription s) { try { assertNull(qs.poll()); - } catch (Exception ex) { + } catch (Throwable ex) { throw new AssertionError(ex); } @@ -285,7 +285,7 @@ public void onSubscribe(Subscription s) { try { assertNull(qs.poll()); - } catch (Exception ex) { + } catch (Throwable ex) { throw new AssertionError(ex); } diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableMapNotificationTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableMapNotificationTest.java index 1346e7bc50..468ffe2586 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableMapNotificationTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableMapNotificationTest.java @@ -13,14 +13,12 @@ package io.reactivex.internal.operators.flowable; -import java.util.concurrent.Callable; - import org.junit.Test; import org.reactivestreams.*; import io.reactivex.*; import io.reactivex.exceptions.*; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; import io.reactivex.internal.functions.Functions; import io.reactivex.internal.operators.flowable.FlowableMapNotification.MapNotificationSubscriber; import io.reactivex.internal.subscriptions.BooleanSubscription; @@ -45,9 +43,9 @@ public Flowable apply(Throwable e) { return Flowable.error(e); } }, - new Callable>() { + new Supplier>() { @Override - public Flowable call() { + public Flowable get() { return Flowable.never(); } } @@ -75,9 +73,9 @@ public Integer apply(Throwable e) { return 0; } }, - new Callable() { + new Supplier() { @Override - public Integer call() { + public Integer get() { return 5; } } @@ -119,9 +117,9 @@ public Integer apply(Throwable e) { return 0; } }, - new Callable() { + new Supplier() { @Override - public Integer call() { + public Integer get() { return 5; } } @@ -158,7 +156,7 @@ protected void subscribeActual(Subscriber subscriber) { subscriber, Functions.justFunction(Flowable.just(1)), Functions.justFunction(Flowable.just(2)), - Functions.justCallable(Flowable.just(3)) + Functions.justSupplier(Flowable.just(3)) ); mn.onSubscribe(new BooleanSubscription()); } @@ -173,7 +171,7 @@ public Flowable apply(Flowable f) throws Exception { return f.flatMap( Functions.justFunction(Flowable.just(1)), Functions.justFunction(Flowable.just(2)), - Functions.justCallable(Flowable.just(3)) + Functions.justSupplier(Flowable.just(3)) ); } }); @@ -189,7 +187,7 @@ public Publisher apply(Throwable t) throws Exception { throw new TestException("Inner"); } }, - Functions.justCallable(Flowable.just(3))) + Functions.justSupplier(Flowable.just(3))) .test() .assertFailure(CompositeException.class); diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableReduceWithSingleTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableReduceWithSingleTest.java index 4b8e64e639..97793612be 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableReduceWithSingleTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableReduceWithSingleTest.java @@ -24,7 +24,7 @@ public class FlowableReduceWithSingleTest { @Test public void normal() { Flowable.range(1, 5) - .reduceWith(Functions.justCallable(1), new BiFunction() { + .reduceWith(Functions.justSupplier(1), new BiFunction() { @Override public Integer apply(Integer a, Integer b) throws Exception { return a + b; @@ -37,7 +37,7 @@ public Integer apply(Integer a, Integer b) throws Exception { @Test public void disposed() { TestHelper.checkDisposed(Flowable.range(1, 5) - .reduceWith(Functions.justCallable(1), new BiFunction() { + .reduceWith(Functions.justSupplier(1), new BiFunction() { @Override public Integer apply(Integer a, Integer b) throws Exception { return a + b; diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableRefCountTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableRefCountTest.java index 673a0f4add..13d61fa5da 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableRefCountTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableRefCountTest.java @@ -548,10 +548,10 @@ public void accept(Subscription s) { .flatMap(new Function>() { @Override public Publisher apply(Long t1) { - return Flowable.defer(new Callable>() { + return Flowable.defer(new Supplier>() { @Override - public Publisher call() { - return Flowable.error(new TestException("Some exception")); + public Publisher get() { + return Flowable.error(new TestException("Some exception")); } }); } diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableReplayTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableReplayTest.java index b3bea718bd..04f7b3dc8f 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableReplayTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableReplayTest.java @@ -512,7 +512,7 @@ public void run() { */ @SuppressWarnings("unchecked") @Test - public void testIssue2191_UnsubscribeSource() throws Exception { + public void testIssue2191_UnsubscribeSource() throws Throwable { // setup mocks Consumer sourceNext = mock(Consumer.class); Action sourceCompleted = mock(Action.class); @@ -562,7 +562,7 @@ public void testIssue2191_UnsubscribeSource() throws Exception { */ @SuppressWarnings("unchecked") @Test - public void testIssue2191_SchedulerUnsubscribe() throws Exception { + public void testIssue2191_SchedulerUnsubscribe() throws Throwable { // setup mocks Consumer sourceNext = mock(Consumer.class); Action sourceCompleted = mock(Action.class); @@ -622,7 +622,7 @@ public void testIssue2191_SchedulerUnsubscribe() throws Exception { */ @SuppressWarnings("unchecked") @Test - public void testIssue2191_SchedulerUnsubscribeOnError() throws Exception { + public void testIssue2191_SchedulerUnsubscribeOnError() throws Throwable { // setup mocks Consumer sourceNext = mock(Consumer.class); Action sourceCompleted = mock(Action.class); @@ -950,7 +950,7 @@ public void accept(String v) { } @Test - public void testUnsubscribeSource() throws Exception { + public void testUnsubscribeSource() throws Throwable { Action unsubscribe = mock(Action.class); Flowable f = Flowable.just(1).doOnCancel(unsubscribe).replay().autoConnect(); f.subscribe(); @@ -1756,9 +1756,9 @@ public Publisher apply(Flowable v) throws Exception { @Test public void multicastSelectorCallableConnectableCrash() { - FlowableReplay.multicastSelector(new Callable>() { + FlowableReplay.multicastSelector(new Supplier>() { @Override - public ConnectableFlowable call() throws Exception { + public ConnectableFlowable get() throws Exception { throw new TestException(); } }, Functions.>identity()) @@ -1944,9 +1944,9 @@ public void noHeadRetentionTime() { @Test(expected = TestException.class) public void createBufferFactoryCrash() { - FlowableReplay.create(Flowable.just(1), new Callable>() { + FlowableReplay.create(Flowable.just(1), new Supplier>() { @Override - public ReplayBuffer call() throws Exception { + public ReplayBuffer get() throws Exception { throw new TestException(); } }) @@ -1955,9 +1955,9 @@ public ReplayBuffer call() throws Exception { @Test public void createBufferFactoryCrashOnSubscribe() { - FlowableReplay.create(Flowable.just(1), new Callable>() { + FlowableReplay.create(Flowable.just(1), new Supplier>() { @Override - public ReplayBuffer call() throws Exception { + public ReplayBuffer get() throws Exception { throw new TestException(); } }) diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableRetryTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableRetryTest.java index a47a5d6eca..67ddc66008 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableRetryTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableRetryTest.java @@ -347,7 +347,7 @@ public void testInfiniteRetry() { */ @SuppressWarnings("unchecked") @Test - public void testRetrySubscribesAgainAfterError() throws Exception { + public void testRetrySubscribesAgainAfterError() throws Throwable { // record emitted values with this action Consumer record = mock(Consumer.class); @@ -1034,9 +1034,9 @@ public void noCancelPreviousRetry() { final AtomicInteger times = new AtomicInteger(); - Flowable source = Flowable.defer(new Callable>() { + Flowable source = Flowable.defer(new Supplier>() { @Override - public Flowable call() throws Exception { + public Flowable get() throws Exception { if (times.getAndIncrement() < 4) { return Flowable.error(new TestException()); } @@ -1063,9 +1063,9 @@ public void noCancelPreviousRetryWhile() { final AtomicInteger times = new AtomicInteger(); - Flowable source = Flowable.defer(new Callable>() { + Flowable source = Flowable.defer(new Supplier>() { @Override - public Flowable call() throws Exception { + public Flowable get() throws Exception { if (times.getAndIncrement() < 4) { return Flowable.error(new TestException()); } @@ -1092,9 +1092,9 @@ public void noCancelPreviousRetryWhile2() { final AtomicInteger times = new AtomicInteger(); - Flowable source = Flowable.defer(new Callable>() { + Flowable source = Flowable.defer(new Supplier>() { @Override - public Flowable call() throws Exception { + public Flowable get() throws Exception { if (times.getAndIncrement() < 4) { return Flowable.error(new TestException()); } @@ -1126,9 +1126,9 @@ public void noCancelPreviousRetryUntil() { final AtomicInteger times = new AtomicInteger(); - Flowable source = Flowable.defer(new Callable>() { + Flowable source = Flowable.defer(new Supplier>() { @Override - public Flowable call() throws Exception { + public Flowable get() throws Exception { if (times.getAndIncrement() < 4) { return Flowable.error(new TestException()); } @@ -1160,9 +1160,9 @@ public void noCancelPreviousRepeatWhen() { final AtomicInteger times = new AtomicInteger(); - Flowable source = Flowable.defer(new Callable>() { + Flowable source = Flowable.defer(new Supplier>() { @Override - public Flowable call() throws Exception { + public Flowable get() throws Exception { if (times.get() < 4) { return Flowable.error(new TestException()); } diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableScalarXMapTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableScalarXMapTest.java index 14f98a6c76..bebfb7178e 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableScalarXMapTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableScalarXMapTest.java @@ -15,14 +15,12 @@ import static org.junit.Assert.*; -import java.util.concurrent.Callable; - import org.junit.Test; import org.reactivestreams.*; import io.reactivex.*; import io.reactivex.exceptions.TestException; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; import io.reactivex.internal.subscriptions.*; import io.reactivex.subscribers.TestSubscriber; @@ -33,38 +31,38 @@ public void utilityClass() { TestHelper.checkUtilityClass(FlowableScalarXMap.class); } - static final class CallablePublisher implements Publisher, Callable { + static final class CallablePublisher implements Publisher, Supplier { @Override public void subscribe(Subscriber s) { EmptySubscription.error(new TestException(), s); } @Override - public Integer call() throws Exception { + public Integer get() throws Exception { throw new TestException(); } } - static final class EmptyCallablePublisher implements Publisher, Callable { + static final class EmptyCallablePublisher implements Publisher, Supplier { @Override public void subscribe(Subscriber s) { EmptySubscription.complete(s); } @Override - public Integer call() throws Exception { + public Integer get() throws Exception { return null; } } - static final class OneCallablePublisher implements Publisher, Callable { + static final class OneCallablePublisher implements Publisher, Supplier { @Override public void subscribe(Subscriber s) { s.onSubscribe(new ScalarSubscription(s, 1)); } @Override - public Integer call() throws Exception { + public Integer get() throws Exception { return 1; } } diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableScanTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableScanTest.java index 7e761ca53f..c36d6f5e4f 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableScanTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableScanTest.java @@ -258,10 +258,10 @@ public void onNext(Integer t) { @Test public void testSeedFactory() { Single> o = Flowable.range(1, 10) - .collect(new Callable>() { + .collect(new Supplier>() { @Override - public List call() { + public List get() { return new ArrayList(); } @@ -284,10 +284,10 @@ public void accept(List list, Integer t2) { @Test public void testSeedFactoryFlowable() { Flowable> f = Flowable.range(1, 10) - .collect(new Callable>() { + .collect(new Supplier>() { @Override - public List call() { + public List get() { return new ArrayList(); } @@ -562,7 +562,7 @@ public void testScanWithSeedCompletesNormally() { @Test public void testScanWithSeedWhenScanSeedProviderThrows() { final RuntimeException e = new RuntimeException(); - Flowable.just(1, 2, 3).scanWith(throwingCallable(e), + Flowable.just(1, 2, 3).scanWith(throwingSupplier(e), SUM) .test() .assertError(e) @@ -648,10 +648,10 @@ public Integer apply(Integer t1, Integer t2) throws Exception { } }; - private static Callable throwingCallable(final RuntimeException e) { - return new Callable() { + private static Supplier throwingSupplier(final RuntimeException e) { + return new Supplier() { @Override - public Integer call() throws Exception { + public Integer get() throws Exception { throw e; } }; diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableThrottleLatestTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableThrottleLatestTest.java index 5612307c28..3f24c56585 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableThrottleLatestTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableThrottleLatestTest.java @@ -182,7 +182,7 @@ public void normalEmitLast() { } @Test - public void missingBackpressureExceptionFirst() throws Exception { + public void missingBackpressureExceptionFirst() throws Throwable { TestScheduler sch = new TestScheduler(); Action onCancel = mock(Action.class); @@ -196,7 +196,7 @@ public void missingBackpressureExceptionFirst() throws Exception { } @Test - public void missingBackpressureExceptionLatest() throws Exception { + public void missingBackpressureExceptionLatest() throws Throwable { TestScheduler sch = new TestScheduler(); Action onCancel = mock(Action.class); @@ -214,7 +214,7 @@ public void missingBackpressureExceptionLatest() throws Exception { } @Test - public void missingBackpressureExceptionLatestComplete() throws Exception { + public void missingBackpressureExceptionLatestComplete() throws Throwable { TestScheduler sch = new TestScheduler(); Action onCancel = mock(Action.class); @@ -238,7 +238,7 @@ public void missingBackpressureExceptionLatestComplete() throws Exception { } @Test - public void take() throws Exception { + public void take() throws Throwable { Action onCancel = mock(Action.class); Flowable.range(1, 5) diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableTimeoutWithSelectorTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableTimeoutWithSelectorTest.java index 178e015413..9622afc5db 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableTimeoutWithSelectorTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableTimeoutWithSelectorTest.java @@ -111,9 +111,9 @@ public Flowable apply(Integer t1) { } }; - Callable> firstTimeoutFunc = new Callable>() { + Supplier> firstTimeoutFunc = new Supplier>() { @Override - public Flowable call() { + public Flowable get() { throw new TestException(); } }; diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableToListTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableToListTest.java index ffa4d0eba3..69aff310a1 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableToListTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableToListTest.java @@ -25,7 +25,7 @@ import io.reactivex.*; import io.reactivex.exceptions.TestException; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; import io.reactivex.observers.TestObserver; import io.reactivex.processors.PublishProcessor; import io.reactivex.schedulers.Schedulers; @@ -342,9 +342,9 @@ public void errorSingle() { @Test public void collectionSupplierThrows() { Flowable.just(1) - .toList(new Callable>() { + .toList(new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { throw new TestException(); } }) @@ -357,9 +357,9 @@ public Collection call() throws Exception { @Test public void collectionSupplierReturnsNull() { Flowable.just(1) - .toList(new Callable>() { + .toList(new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { return null; } }) @@ -373,9 +373,9 @@ public Collection call() throws Exception { @Test public void singleCollectionSupplierThrows() { Flowable.just(1) - .toList(new Callable>() { + .toList(new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { throw new TestException(); } }) @@ -387,9 +387,9 @@ public Collection call() throws Exception { @Test public void singleCollectionSupplierReturnsNull() { Flowable.just(1) - .toList(new Callable>() { + .toList(new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { return null; } }) diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableToMapTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableToMapTest.java index 296f68eef6..ab8cff04ed 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableToMapTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableToMapTest.java @@ -13,16 +13,16 @@ package io.reactivex.internal.operators.flowable; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; import java.util.*; -import java.util.concurrent.Callable; import org.junit.*; import org.reactivestreams.Subscriber; import io.reactivex.*; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; public class FlowableToMapTest { Subscriber objectSubscriber; @@ -148,9 +148,9 @@ public String apply(String t1) { public void testToMapWithFactoryFlowable() { Flowable source = Flowable.just("a", "bb", "ccc", "dddd"); - Callable> mapFactory = new Callable>() { + Supplier> mapFactory = new Supplier>() { @Override - public Map call() { + public Map get() { return new LinkedHashMap() { private static final long serialVersionUID = -3296811238780863394L; @@ -192,9 +192,9 @@ public String apply(String v) { public void testToMapWithErrorThrowingFactoryFlowable() { Flowable source = Flowable.just("a", "bb", "ccc", "dddd"); - Callable> mapFactory = new Callable>() { + Supplier> mapFactory = new Supplier>() { @Override - public Map call() { + public Map get() { throw new RuntimeException("Forced failure"); } }; @@ -321,9 +321,9 @@ public String apply(String t1) { public void testToMapWithFactory() { Flowable source = Flowable.just("a", "bb", "ccc", "dddd"); - Callable> mapFactory = new Callable>() { + Supplier> mapFactory = new Supplier>() { @Override - public Map call() { + public Map get() { return new LinkedHashMap() { private static final long serialVersionUID = -3296811238780863394L; @@ -364,9 +364,9 @@ public String apply(String v) { public void testToMapWithErrorThrowingFactory() { Flowable source = Flowable.just("a", "bb", "ccc", "dddd"); - Callable> mapFactory = new Callable>() { + Supplier> mapFactory = new Supplier>() { @Override - public Map call() { + public Map get() { throw new RuntimeException("Forced failure"); } }; diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableToMultimapTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableToMultimapTest.java index bb77dab822..a45e2dfa65 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableToMultimapTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableToMultimapTest.java @@ -13,16 +13,16 @@ package io.reactivex.internal.operators.flowable; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; import java.util.*; -import java.util.concurrent.Callable; import org.junit.*; import org.reactivestreams.Subscriber; import io.reactivex.*; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; public class FlowableToMultimapTest { Subscriber objectSubscriber; @@ -86,9 +86,9 @@ public void testToMultimapWithValueSelectorFlowable() { public void testToMultimapWithMapFactoryFlowable() { Flowable source = Flowable.just("a", "b", "cc", "dd", "eee", "fff"); - Callable>> mapFactory = new Callable>>() { + Supplier>> mapFactory = new Supplier>>() { @Override - public Map> call() { + public Map> get() { return new LinkedHashMap>() { private static final long serialVersionUID = -2084477070717362859L; @@ -149,9 +149,9 @@ public String apply(String v) { return v; } }; - Callable>> mapSupplier = new Callable>>() { + Supplier>> mapSupplier = new Supplier>>() { @Override - public Map> call() { + public Map> get() { return new HashMap>(); } }; @@ -228,9 +228,9 @@ public String apply(String t1) { public void testToMultimapWithMapThrowingFactoryFlowable() { Flowable source = Flowable.just("a", "b", "cc", "dd", "eee", "fff"); - Callable>> mapFactory = new Callable>>() { + Supplier>> mapFactory = new Supplier>>() { @Override - public Map> call() { + public Map> get() { throw new RuntimeException("Forced failure"); } }; @@ -275,9 +275,9 @@ public String apply(String v) { return v; } }; - Callable>> mapSupplier = new Callable>>() { + Supplier>> mapSupplier = new Supplier>>() { @Override - public Map> call() { + public Map> get() { return new HashMap>(); } }; @@ -332,9 +332,9 @@ public void testToMultimapWithValueSelector() { public void testToMultimapWithMapFactory() { Flowable source = Flowable.just("a", "b", "cc", "dd", "eee", "fff"); - Callable>> mapFactory = new Callable>>() { + Supplier>> mapFactory = new Supplier>>() { @Override - public Map> call() { + public Map> get() { return new LinkedHashMap>() { private static final long serialVersionUID = -2084477070717362859L; @@ -394,9 +394,9 @@ public String apply(String v) { return v; } }; - Callable>> mapSupplier = new Callable>>() { + Supplier>> mapSupplier = new Supplier>>() { @Override - public Map> call() { + public Map> get() { return new HashMap>(); } }; @@ -470,9 +470,9 @@ public String apply(String t1) { public void testToMultimapWithMapThrowingFactory() { Flowable source = Flowable.just("a", "b", "cc", "dd", "eee", "fff"); - Callable>> mapFactory = new Callable>>() { + Supplier>> mapFactory = new Supplier>>() { @Override - public Map> call() { + public Map> get() { throw new RuntimeException("Forced failure"); } }; @@ -516,9 +516,9 @@ public String apply(String v) { return v; } }; - Callable>> mapSupplier = new Callable>>() { + Supplier>> mapSupplier = new Supplier>>() { @Override - public Map> call() { + public Map> get() { return new HashMap>(); } }; diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableUsingTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableUsingTest.java index cfc8ab20b1..5c7c0b1724 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableUsingTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableUsingTest.java @@ -17,7 +17,6 @@ import static org.mockito.Mockito.*; import java.util.*; -import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicInteger; import org.junit.*; @@ -73,9 +72,9 @@ private void performTestUsing(boolean disposeEagerly) { final Resource resource = mock(Resource.class); when(resource.getTextFromWeb()).thenReturn("Hello world!"); - Callable resourceFactory = new Callable() { + Supplier resourceFactory = new Supplier() { @Override - public Resource call() { + public Resource get() { return resource; } }; @@ -115,9 +114,9 @@ public void testUsingWithSubscribingTwiceDisposeEagerly() { private void performTestUsingWithSubscribingTwice(boolean disposeEagerly) { // When subscribe is called, a new resource should be created. - Callable resourceFactory = new Callable() { + Supplier resourceFactory = new Supplier() { @Override - public Resource call() { + public Resource get() { return new Resource() { boolean first = true; @@ -177,9 +176,9 @@ public void testUsingWithResourceFactoryErrorDisposeEagerly() { } private void performTestUsingWithResourceFactoryError(boolean disposeEagerly) { - Callable resourceFactory = new Callable() { + Supplier resourceFactory = new Supplier() { @Override - public Disposable call() { + public Disposable get() { throw new TestException(); } }; @@ -207,9 +206,9 @@ public void testUsingWithFlowableFactoryErrorDisposeEagerly() { private void performTestUsingWithFlowableFactoryError(boolean disposeEagerly) { final Runnable unsubscribe = mock(Runnable.class); - Callable resourceFactory = new Callable() { + Supplier resourceFactory = new Supplier() { @Override - public Disposable call() { + public Disposable get() { return Disposables.fromRunnable(unsubscribe); } }; @@ -245,9 +244,9 @@ public void testUsingWithFlowableFactoryErrorInOnSubscribeDisposeEagerly() { private void performTestUsingWithFlowableFactoryErrorInOnSubscribe(boolean disposeEagerly) { final Runnable unsubscribe = mock(Runnable.class); - Callable resourceFactory = new Callable() { + Supplier resourceFactory = new Supplier() { @Override - public Disposable call() { + public Disposable get() { return Disposables.fromRunnable(unsubscribe); } }; @@ -280,7 +279,7 @@ public void subscribe(Subscriber t1) { @Test public void testUsingDisposesEagerlyBeforeCompletion() { final List events = new ArrayList(); - Callable resourceFactory = createResourceFactory(events); + Supplier resourceFactory = createResourceFactory(events); final Action completion = createOnCompletedAction(events); final Action unsub = createUnsubAction(events); @@ -307,7 +306,7 @@ public Flowable apply(Resource resource) { @Test public void testUsingDoesNotDisposesEagerlyBeforeCompletion() { final List events = new ArrayList(); - Callable resourceFactory = createResourceFactory(events); + Supplier resourceFactory = createResourceFactory(events); final Action completion = createOnCompletedAction(events); final Action unsub = createUnsubAction(events); @@ -334,7 +333,7 @@ public Flowable apply(Resource resource) { @Test public void testUsingDisposesEagerlyBeforeError() { final List events = new ArrayList(); - Callable resourceFactory = createResourceFactory(events); + Supplier resourceFactory = createResourceFactory(events); final Consumer onError = createOnErrorAction(events); final Action unsub = createUnsubAction(events); @@ -362,7 +361,7 @@ public Flowable apply(Resource resource) { @Test public void testUsingDoesNotDisposesEagerlyBeforeError() { final List events = new ArrayList(); - final Callable resourceFactory = createResourceFactory(events); + final Supplier resourceFactory = createResourceFactory(events); final Consumer onError = createOnErrorAction(events); final Action unsub = createUnsubAction(events); @@ -404,10 +403,10 @@ public void accept(Throwable t) { }; } - private static Callable createResourceFactory(final List events) { - return new Callable() { + private static Supplier createResourceFactory(final List events) { + return new Supplier() { @Override - public Resource call() { + public Resource get() { return new Resource() { @Override @@ -441,9 +440,9 @@ public void factoryThrows() { final AtomicInteger count = new AtomicInteger(); Flowable.using( - new Callable() { + new Supplier() { @Override - public Integer call() { + public Integer get() { return 1; } }, @@ -475,9 +474,9 @@ public void nonEagerTermination() { final AtomicInteger count = new AtomicInteger(); Flowable.using( - new Callable() { + new Supplier() { @Override - public Integer call() { + public Integer get() { return 1; } }, @@ -506,9 +505,9 @@ public void accept(Integer c) { @Test public void dispose() { TestHelper.checkDisposed(Flowable.using( - new Callable() { + new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, @@ -524,9 +523,9 @@ public Flowable apply(Object v) throws Exception { @Test public void supplierDisposerCrash() { - TestSubscriber ts = Flowable.using(new Callable() { + TestSubscriber ts = Flowable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { @@ -551,9 +550,9 @@ public void accept(Object e) throws Exception { @Test public void eagerOnErrorDisposerCrash() { - TestSubscriber ts = Flowable.using(new Callable() { + TestSubscriber ts = Flowable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { @@ -578,9 +577,9 @@ public void accept(Object e) throws Exception { @Test public void eagerOnCompleteDisposerCrash() { - Flowable.using(new Callable() { + Flowable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { @@ -602,9 +601,9 @@ public void accept(Object e) throws Exception { public void nonEagerDisposerCrash() { List errors = TestHelper.trackPluginErrors(); try { - Flowable.using(new Callable() { + Flowable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { @@ -629,7 +628,7 @@ public void accept(Object e) throws Exception { @Test public void sourceSupplierReturnsNull() { - Flowable.using(Functions.justCallable(1), + Flowable.using(Functions.justSupplier(1), Functions.justFunction((Publisher)null), Functions.emptyConsumer()) .test() @@ -643,7 +642,7 @@ public void doubleOnSubscribe() { @Override public Flowable apply(Flowable f) throws Exception { - return Flowable.using(Functions.justCallable(1), Functions.justFunction(f), Functions.emptyConsumer()); + return Flowable.using(Functions.justSupplier(1), Functions.justFunction(f), Functions.emptyConsumer()); } }); } @@ -652,7 +651,7 @@ public Flowable apply(Flowable f) public void eagerDisposedOnComplete() { final TestSubscriber ts = new TestSubscriber(); - Flowable.using(Functions.justCallable(1), Functions.justFunction(new Flowable() { + Flowable.using(Functions.justSupplier(1), Functions.justFunction(new Flowable() { @Override protected void subscribeActual(Subscriber subscriber) { subscriber.onSubscribe(new BooleanSubscription()); @@ -667,7 +666,7 @@ protected void subscribeActual(Subscriber subscriber) { public void eagerDisposedOnError() { final TestSubscriber ts = new TestSubscriber(); - Flowable.using(Functions.justCallable(1), Functions.justFunction(new Flowable() { + Flowable.using(Functions.justSupplier(1), Functions.justFunction(new Flowable() { @Override protected void subscribeActual(Subscriber subscriber) { subscriber.onSubscribe(new BooleanSubscription()); diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableWindowWithFlowableTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableWindowWithFlowableTest.java index 919ca0e468..1719eff6dc 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableWindowWithFlowableTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableWindowWithFlowableTest.java @@ -26,7 +26,7 @@ import io.reactivex.*; import io.reactivex.exceptions.*; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; import io.reactivex.internal.functions.Functions; import io.reactivex.internal.subscriptions.BooleanSubscription; import io.reactivex.plugins.RxJavaPlugins; @@ -269,9 +269,9 @@ public void onNext(Flowable t) { super.onNext(t); } }; - source.window(new Callable>() { + source.window(new Supplier>() { @Override - public Flowable call() { + public Flowable get() { return Flowable.never(); } }).subscribe(ts); @@ -286,9 +286,9 @@ public Flowable call() { @Test public void testWindowViaFlowableNoUnsubscribe() { Flowable source = Flowable.range(1, 10); - Callable> boundary = new Callable>() { + Supplier> boundary = new Supplier>() { @Override - public Flowable call() { + public Flowable get() { return Flowable.empty(); } }; @@ -303,9 +303,9 @@ public Flowable call() { public void testBoundaryUnsubscribedOnMainCompletion() { PublishProcessor source = PublishProcessor.create(); final PublishProcessor boundary = PublishProcessor.create(); - Callable> boundaryFunc = new Callable>() { + Supplier> boundaryFunc = new Supplier>() { @Override - public Flowable call() { + public Flowable get() { return boundary; } }; @@ -330,9 +330,9 @@ public Flowable call() { public void testMainUnsubscribedOnBoundaryCompletion() { PublishProcessor source = PublishProcessor.create(); final PublishProcessor boundary = PublishProcessor.create(); - Callable> boundaryFunc = new Callable>() { + Supplier> boundaryFunc = new Supplier>() { @Override - public Flowable call() { + public Flowable get() { return boundary; } }; @@ -357,9 +357,9 @@ public Flowable call() { public void testChildUnsubscribed() { PublishProcessor source = PublishProcessor.create(); final PublishProcessor boundary = PublishProcessor.create(); - Callable> boundaryFunc = new Callable>() { + Supplier> boundaryFunc = new Supplier>() { @Override - public Flowable call() { + public Flowable get() { return boundary; } }; @@ -389,9 +389,9 @@ public Flowable call() { public void testInnerBackpressure() { Flowable source = Flowable.range(1, 10); final PublishProcessor boundary = PublishProcessor.create(); - Callable> boundaryFunc = new Callable>() { + Supplier> boundaryFunc = new Supplier>() { @Override - public Flowable call() { + public Flowable get() { return boundary; } }; @@ -427,9 +427,9 @@ public void newBoundaryCalledAfterWindowClosed() { final AtomicInteger calls = new AtomicInteger(); PublishProcessor source = PublishProcessor.create(); final PublishProcessor boundary = PublishProcessor.create(); - Callable> boundaryFunc = new Callable>() { + Supplier> boundaryFunc = new Supplier>() { @Override - public Flowable call() { + public Flowable get() { calls.getAndIncrement(); return boundary; } @@ -468,7 +468,7 @@ public void boundaryDispose() { @Test public void boundaryDispose2() { - TestHelper.checkDisposed(Flowable.never().window(Functions.justCallable(Flowable.never()))); + TestHelper.checkDisposed(Flowable.never().window(Functions.justSupplier(Flowable.never()))); } @Test @@ -487,7 +487,7 @@ public void boundaryOnError() { @Test public void mainError() { Flowable.error(new TestException()) - .window(Functions.justCallable(Flowable.never())) + .window(Functions.justSupplier(Flowable.never())) .test() .assertError(TestException.class); } @@ -509,10 +509,10 @@ public Flowable apply(Flowable v) throws Exception { TestHelper.checkBadSourceFlowable(new Function, Object>() { @Override public Object apply(final Flowable f) throws Exception { - return Flowable.just(1).window(new Callable>() { + return Flowable.just(1).window(new Supplier>() { int count; @Override - public Publisher call() throws Exception { + public Publisher get() throws Exception { if (++count > 1) { return Flowable.never(); } @@ -575,10 +575,10 @@ public void onNext(Integer t) { } }; - ps.window(new Callable>() { + ps.window(new Supplier>() { boolean once; @Override - public Flowable call() throws Exception { + public Flowable get() throws Exception { if (!once) { once = true; return BehaviorProcessor.createDefault(1); @@ -621,7 +621,7 @@ public void badSourceCallable() { TestHelper.checkBadSourceFlowable(new Function, Object>() { @Override public Object apply(Flowable f) throws Exception { - return f.window(Functions.justCallable(Flowable.never())).flatMap(new Function, Flowable>() { + return f.window(Functions.justSupplier(Flowable.never())).flatMap(new Function, Flowable>() { @Override public Flowable apply(Flowable v) throws Exception { return v; @@ -634,7 +634,7 @@ public Flowable apply(Flowable v) throws Exception { @Test public void boundaryError() { BehaviorProcessor.createDefault(1) - .window(Functions.justCallable(Flowable.error(new TestException()))) + .window(Functions.justSupplier(Flowable.error(new TestException()))) .test() .assertValueCount(1) .assertNotComplete() @@ -645,7 +645,7 @@ public void boundaryError() { @Test public void boundaryMissingBackpressure() { BehaviorProcessor.createDefault(1) - .window(Functions.justCallable(Flowable.error(new TestException()))) + .window(Functions.justSupplier(Flowable.error(new TestException()))) .test(0) .assertFailure(MissingBackpressureException.class); } @@ -653,10 +653,10 @@ public void boundaryMissingBackpressure() { @Test public void boundaryCallableCrashOnCall2() { BehaviorProcessor.createDefault(1) - .window(new Callable>() { + .window(new Supplier>() { int calls; @Override - public Flowable call() throws Exception { + public Flowable get() throws Exception { if (++calls == 2) { throw new TestException(); } @@ -671,7 +671,7 @@ public Flowable call() throws Exception { @Test public void boundarySecondMissingBackpressure() { BehaviorProcessor.createDefault(1) - .window(Functions.justCallable(Flowable.just(1))) + .window(Functions.justSupplier(Flowable.just(1))) .test(1) .assertError(MissingBackpressureException.class) .assertNotComplete(); @@ -682,7 +682,7 @@ public void oneWindow() { PublishProcessor pp = PublishProcessor.create(); TestSubscriber> ts = BehaviorProcessor.createDefault(1) - .window(Functions.justCallable(pp)) + .window(Functions.justSupplier(pp)) .take(1) .test(); @@ -1047,7 +1047,7 @@ public void boundarySupplierDoubleOnSubscribe() { @Override public Flowable> apply(Flowable f) throws Exception { - return f.window(Functions.justCallable(Flowable.never())).takeLast(1); + return f.window(Functions.justSupplier(Flowable.never())).takeLast(1); } }); } @@ -1057,7 +1057,7 @@ public void selectorUpstreamDisposedWhenOutputsDisposed() { PublishProcessor source = PublishProcessor.create(); PublishProcessor boundary = PublishProcessor.create(); - TestSubscriber ts = source.window(Functions.justCallable(boundary)) + TestSubscriber ts = source.window(Functions.justSupplier(boundary)) .take(1) .flatMap(new Function, Flowable>() { @Override @@ -1083,7 +1083,7 @@ public void supplierMainAndBoundaryBothError() { final AtomicReference> ref = new AtomicReference>(); TestSubscriber> ts = Flowable.error(new TestException("main")) - .window(Functions.justCallable(new Flowable() { + .window(Functions.justSupplier(new Flowable() { @Override protected void subscribeActual(Subscriber subscriber) { subscriber.onSubscribe(new BooleanSubscription()); @@ -1123,7 +1123,7 @@ protected void subscribeActual(Subscriber subscriber) { refMain.set(subscriber); } } - .window(Functions.justCallable(new Flowable() { + .window(Functions.justSupplier(new Flowable() { @Override protected void subscribeActual(Subscriber subscriber) { subscriber.onSubscribe(new BooleanSubscription()); @@ -1173,7 +1173,7 @@ protected void subscribeActual(Subscriber subscriber) { refMain.set(subscriber); } } - .window(Functions.justCallable(new Flowable() { + .window(Functions.justSupplier(new Flowable() { @Override protected void subscribeActual(Subscriber subscriber) { subscriber.onSubscribe(new BooleanSubscription()); @@ -1216,7 +1216,7 @@ protected void subscribeActual(Subscriber subscriber) { refMain.set(subscriber); } } - .window(Functions.justCallable(new Flowable() { + .window(Functions.justSupplier(new Flowable() { @Override protected void subscribeActual(Subscriber subscriber) { subscriber.onSubscribe(new BooleanSubscription()); @@ -1248,7 +1248,7 @@ protected void subscribeActual(Subscriber subscriber) { refMain.set(subscriber); } } - .window(Functions.justCallable(new Flowable() { + .window(Functions.justSupplier(new Flowable() { @Override protected void subscribeActual(Subscriber subscriber) { final AtomicInteger counter = new AtomicInteger(); @@ -1307,10 +1307,10 @@ protected void subscribeActual(Subscriber subscriber) { refMain.set(subscriber); } } - .window(new Callable>() { + .window(new Supplier>() { int count; @Override - public Flowable call() throws Exception { + public Flowable get() throws Exception { if (++count > 1) { return Flowable.never(); } diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableWindowWithStartEndFlowableTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableWindowWithStartEndFlowableTest.java index 1d27381129..965d278a23 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableWindowWithStartEndFlowableTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableWindowWithStartEndFlowableTest.java @@ -112,10 +112,10 @@ public void subscribe(Subscriber subscriber) { } }); - Callable> closer = new Callable>() { + Supplier> closer = new Supplier>() { int calls; @Override - public Flowable call() { + public Flowable get() { return Flowable.unsafeCreate(new Publisher() { @Override public void subscribe(Subscriber subscriber) { diff --git a/src/test/java/io/reactivex/internal/operators/maybe/MaybeEmptyTest.java b/src/test/java/io/reactivex/internal/operators/maybe/MaybeEmptyTest.java index 9523a463ea..a47dddc4f6 100644 --- a/src/test/java/io/reactivex/internal/operators/maybe/MaybeEmptyTest.java +++ b/src/test/java/io/reactivex/internal/operators/maybe/MaybeEmptyTest.java @@ -18,16 +18,16 @@ import org.junit.Test; import io.reactivex.Maybe; -import io.reactivex.internal.fuseable.ScalarCallable; +import io.reactivex.internal.fuseable.ScalarSupplier; public class MaybeEmptyTest { @Test - public void scalarCallable() { + public void scalarSupplier() { Maybe m = Maybe.empty(); - assertTrue(m.getClass().toString(), m instanceof ScalarCallable); + assertTrue(m.getClass().toString(), m instanceof ScalarSupplier); - assertNull(((ScalarCallable)m).call()); + assertNull(((ScalarSupplier)m).get()); } } diff --git a/src/test/java/io/reactivex/internal/operators/maybe/MaybeErrorTest.java b/src/test/java/io/reactivex/internal/operators/maybe/MaybeErrorTest.java index e946915d6b..0b8ece45af 100644 --- a/src/test/java/io/reactivex/internal/operators/maybe/MaybeErrorTest.java +++ b/src/test/java/io/reactivex/internal/operators/maybe/MaybeErrorTest.java @@ -13,20 +13,19 @@ package io.reactivex.internal.operators.maybe; -import java.util.concurrent.Callable; - import org.junit.Test; import io.reactivex.Maybe; import io.reactivex.exceptions.TestException; +import io.reactivex.functions.Supplier; public class MaybeErrorTest { @Test - public void errorCallableThrows() { - Maybe.error(new Callable() { + public void errorSupplierThrows() { + Maybe.error(new Supplier() { @Override - public Throwable call() throws Exception { + public Throwable get() throws Exception { throw new TestException(); } }) diff --git a/src/test/java/io/reactivex/internal/operators/maybe/MaybeFlatMapNotificationTest.java b/src/test/java/io/reactivex/internal/operators/maybe/MaybeFlatMapNotificationTest.java index 6f0cee2ac1..99427f91b9 100644 --- a/src/test/java/io/reactivex/internal/operators/maybe/MaybeFlatMapNotificationTest.java +++ b/src/test/java/io/reactivex/internal/operators/maybe/MaybeFlatMapNotificationTest.java @@ -29,7 +29,7 @@ public class MaybeFlatMapNotificationTest { public void dispose() { TestHelper.checkDisposed(Maybe.just(1) .flatMap(Functions.justFunction(Maybe.just(1)), - Functions.justFunction(Maybe.just(1)), Functions.justCallable(Maybe.just(1)))); + Functions.justFunction(Maybe.just(1)), Functions.justSupplier(Maybe.just(1)))); } @Test @@ -39,7 +39,7 @@ public void doubleOnSubscribe() { public MaybeSource apply(Maybe m) throws Exception { return m .flatMap(Functions.justFunction(Maybe.just(1)), - Functions.justFunction(Maybe.just(1)), Functions.justCallable(Maybe.just(1))); + Functions.justFunction(Maybe.just(1)), Functions.justSupplier(Maybe.just(1))); } }); } @@ -49,7 +49,7 @@ public void onSuccessNull() { Maybe.just(1) .flatMap(Functions.justFunction((Maybe)null), Functions.justFunction(Maybe.just(1)), - Functions.justCallable(Maybe.just(1))) + Functions.justSupplier(Maybe.just(1))) .test() .assertFailure(NullPointerException.class); } @@ -59,7 +59,7 @@ public void onErrorNull() { TestObserver to = Maybe.error(new TestException()) .flatMap(Functions.justFunction(Maybe.just(1)), Functions.justFunction((Maybe)null), - Functions.justCallable(Maybe.just(1))) + Functions.justSupplier(Maybe.just(1))) .test() .assertFailure(CompositeException.class); @@ -74,7 +74,7 @@ public void onCompleteNull() { Maybe.empty() .flatMap(Functions.justFunction(Maybe.just(1)), Functions.justFunction(Maybe.just(1)), - Functions.justCallable((Maybe)null)) + Functions.justSupplier((Maybe)null)) .test() .assertFailure(NullPointerException.class); } @@ -84,7 +84,7 @@ public void onSuccessEmpty() { Maybe.just(1) .flatMap(Functions.justFunction(Maybe.empty()), Functions.justFunction(Maybe.just(1)), - Functions.justCallable(Maybe.just(1))) + Functions.justSupplier(Maybe.just(1))) .test() .assertResult(); } @@ -94,7 +94,7 @@ public void onSuccessError() { Maybe.just(1) .flatMap(Functions.justFunction(Maybe.error(new TestException())), Functions.justFunction((Maybe)null), - Functions.justCallable(Maybe.just(1))) + Functions.justSupplier(Maybe.just(1))) .test() .assertFailure(TestException.class); } diff --git a/src/test/java/io/reactivex/internal/operators/maybe/MaybeFromActionTest.java b/src/test/java/io/reactivex/internal/operators/maybe/MaybeFromActionTest.java index 6e7c1b242f..02a289c084 100644 --- a/src/test/java/io/reactivex/internal/operators/maybe/MaybeFromActionTest.java +++ b/src/test/java/io/reactivex/internal/operators/maybe/MaybeFromActionTest.java @@ -23,7 +23,7 @@ import org.junit.Test; import io.reactivex.*; -import io.reactivex.functions.Action; +import io.reactivex.functions.*; import io.reactivex.observers.TestObserver; import io.reactivex.plugins.RxJavaPlugins; import io.reactivex.schedulers.Schedulers; @@ -108,7 +108,7 @@ public void run() throws Exception { @SuppressWarnings("unchecked") @Test - public void callable() throws Exception { + public void callable() throws Throwable { final int[] counter = { 0 }; Maybe m = Maybe.fromAction(new Action() { @@ -118,9 +118,9 @@ public void run() throws Exception { } }); - assertTrue(m.getClass().toString(), m instanceof Callable); + assertTrue(m.getClass().toString(), m instanceof Supplier); - assertNull(((Callable)m).call()); + assertNull(((Supplier)m).get()); assertEquals(1, counter[0]); } @@ -157,7 +157,7 @@ public void run() throws Exception { } @Test - public void disposedUpfront() throws Exception { + public void disposedUpfront() throws Throwable { Action run = mock(Action.class); Maybe.fromAction(run) diff --git a/src/test/java/io/reactivex/internal/operators/maybe/MaybeFromCallableTest.java b/src/test/java/io/reactivex/internal/operators/maybe/MaybeFromCallableTest.java index 7a56347a32..c4ec8c267d 100644 --- a/src/test/java/io/reactivex/internal/operators/maybe/MaybeFromCallableTest.java +++ b/src/test/java/io/reactivex/internal/operators/maybe/MaybeFromCallableTest.java @@ -21,15 +21,16 @@ import java.util.concurrent.*; import java.util.concurrent.atomic.AtomicInteger; -import io.reactivex.disposables.Disposable; import org.junit.Test; +import org.mockito.invocation.InvocationOnMock; +import org.mockito.stubbing.Answer; import io.reactivex.*; +import io.reactivex.disposables.Disposable; +import io.reactivex.functions.Supplier; import io.reactivex.observers.TestObserver; import io.reactivex.plugins.RxJavaPlugins; import io.reactivex.schedulers.Schedulers; -import org.mockito.invocation.InvocationOnMock; -import org.mockito.stubbing.Answer; public class MaybeFromCallableTest { @Test(expected = NullPointerException.class) @@ -114,7 +115,7 @@ public Object call() throws Exception { @SuppressWarnings("unchecked") @Test - public void callable() throws Exception { + public void callable() throws Throwable { final int[] counter = { 0 }; Maybe m = Maybe.fromCallable(new Callable() { @@ -125,9 +126,9 @@ public Integer call() throws Exception { } }); - assertTrue(m.getClass().toString(), m instanceof Callable); + assertTrue(m.getClass().toString(), m instanceof Supplier); - assertEquals(0, ((Callable)m).call()); + assertEquals(0, ((Supplier)m).get()); assertEquals(1, counter[0]); } diff --git a/src/test/java/io/reactivex/internal/operators/maybe/MaybeFromRunnableTest.java b/src/test/java/io/reactivex/internal/operators/maybe/MaybeFromRunnableTest.java index 08d0bbc4b3..3236c5f45f 100644 --- a/src/test/java/io/reactivex/internal/operators/maybe/MaybeFromRunnableTest.java +++ b/src/test/java/io/reactivex/internal/operators/maybe/MaybeFromRunnableTest.java @@ -23,6 +23,7 @@ import org.junit.Test; import io.reactivex.*; +import io.reactivex.functions.Supplier; import io.reactivex.observers.TestObserver; import io.reactivex.plugins.RxJavaPlugins; import io.reactivex.schedulers.Schedulers; @@ -106,7 +107,7 @@ public void run() { @SuppressWarnings("unchecked") @Test - public void callable() throws Exception { + public void callable() throws Throwable { final int[] counter = { 0 }; Maybe m = Maybe.fromRunnable(new Runnable() { @@ -116,9 +117,9 @@ public void run() { } }); - assertTrue(m.getClass().toString(), m instanceof Callable); + assertTrue(m.getClass().toString(), m instanceof Supplier); - assertNull(((Callable)m).call()); + assertNull(((Supplier)m).get()); assertEquals(1, counter[0]); } diff --git a/src/test/java/io/reactivex/internal/operators/maybe/MaybeHideTest.java b/src/test/java/io/reactivex/internal/operators/maybe/MaybeHideTest.java index 51ec1c812e..c1b30e5b1b 100644 --- a/src/test/java/io/reactivex/internal/operators/maybe/MaybeHideTest.java +++ b/src/test/java/io/reactivex/internal/operators/maybe/MaybeHideTest.java @@ -20,7 +20,7 @@ import io.reactivex.*; import io.reactivex.exceptions.TestException; import io.reactivex.functions.Function; -import io.reactivex.internal.fuseable.ScalarCallable; +import io.reactivex.internal.fuseable.ScalarSupplier; import io.reactivex.processors.PublishProcessor; public class MaybeHideTest { @@ -51,9 +51,9 @@ public void error() { @Test public void hidden() { - assertTrue(Maybe.just(1) instanceof ScalarCallable); + assertTrue(Maybe.just(1) instanceof ScalarSupplier); - assertFalse(Maybe.just(1).hide() instanceof ScalarCallable); + assertFalse(Maybe.just(1).hide() instanceof ScalarSupplier); } @Test diff --git a/src/test/java/io/reactivex/internal/operators/maybe/MaybeJustTest.java b/src/test/java/io/reactivex/internal/operators/maybe/MaybeJustTest.java index f263ae722c..fc3d5f0d2c 100644 --- a/src/test/java/io/reactivex/internal/operators/maybe/MaybeJustTest.java +++ b/src/test/java/io/reactivex/internal/operators/maybe/MaybeJustTest.java @@ -18,17 +18,17 @@ import org.junit.Test; import io.reactivex.Maybe; -import io.reactivex.internal.fuseable.ScalarCallable; +import io.reactivex.internal.fuseable.ScalarSupplier; public class MaybeJustTest { @SuppressWarnings("unchecked") @Test - public void scalarCallable() { + public void scalarSupplier() { Maybe m = Maybe.just(1); - assertTrue(m.getClass().toString(), m instanceof ScalarCallable); + assertTrue(m.getClass().toString(), m instanceof ScalarSupplier); - assertEquals(1, ((ScalarCallable)m).call().intValue()); + assertEquals(1, ((ScalarSupplier)m).get().intValue()); } } diff --git a/src/test/java/io/reactivex/internal/operators/maybe/MaybeUsingTest.java b/src/test/java/io/reactivex/internal/operators/maybe/MaybeUsingTest.java index d007667097..a4557d415b 100644 --- a/src/test/java/io/reactivex/internal/operators/maybe/MaybeUsingTest.java +++ b/src/test/java/io/reactivex/internal/operators/maybe/MaybeUsingTest.java @@ -16,7 +16,6 @@ import static org.junit.Assert.*; import java.util.List; -import java.util.concurrent.Callable; import org.junit.Test; @@ -33,9 +32,9 @@ public class MaybeUsingTest { @Test public void resourceSupplierThrows() { - Maybe.using(new Callable() { + Maybe.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { throw new TestException(); } }, new Function>() { @@ -56,9 +55,9 @@ public void accept(Object d) throws Exception { @Test public void errorEager() { - Maybe.using(new Callable() { + Maybe.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { @@ -79,9 +78,9 @@ public void accept(Object d) throws Exception { @Test public void emptyEager() { - Maybe.using(new Callable() { + Maybe.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { @@ -102,9 +101,9 @@ public void accept(Object d) throws Exception { @Test public void errorNonEager() { - Maybe.using(new Callable() { + Maybe.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { @@ -125,9 +124,9 @@ public void accept(Object d) throws Exception { @Test public void emptyNonEager() { - Maybe.using(new Callable() { + Maybe.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { @@ -148,9 +147,9 @@ public void accept(Object d) throws Exception { @Test public void supplierCrashEager() { - Maybe.using(new Callable() { + Maybe.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { @@ -171,9 +170,9 @@ public void accept(Object d) throws Exception { @Test public void supplierCrashNonEager() { - Maybe.using(new Callable() { + Maybe.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { @@ -193,9 +192,9 @@ public void accept(Object d) throws Exception { @Test public void supplierAndDisposerCrashEager() { - TestObserver to = Maybe.using(new Callable() { + TestObserver to = Maybe.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { @@ -222,9 +221,9 @@ public void accept(Object d) throws Exception { public void supplierAndDisposerCrashNonEager() { List errors = TestHelper.trackPluginErrors(); try { - Maybe.using(new Callable() { + Maybe.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { @@ -251,9 +250,9 @@ public void accept(Object d) throws Exception { public void dispose() { final int[] call = {0 }; - TestObserver to = Maybe.using(new Callable() { + TestObserver to = Maybe.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { @@ -278,9 +277,9 @@ public void accept(Object d) throws Exception { public void disposeCrashes() { List errors = TestHelper.trackPluginErrors(); try { - TestObserver to = Maybe.using(new Callable() { + TestObserver to = Maybe.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { @@ -306,9 +305,9 @@ public void accept(Object d) throws Exception { @Test public void isDisposed() { - TestHelper.checkDisposed(Maybe.using(new Callable() { + TestHelper.checkDisposed(Maybe.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { @@ -326,9 +325,9 @@ public void accept(Object d) throws Exception { @Test public void justDisposerCrashes() { - Maybe.using(new Callable() { + Maybe.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { @@ -348,9 +347,9 @@ public void accept(Object d) throws Exception { @Test public void emptyDisposerCrashes() { - Maybe.using(new Callable() { + Maybe.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { @@ -370,9 +369,9 @@ public void accept(Object d) throws Exception { @Test public void errorDisposerCrash() { - TestObserver to = Maybe.using(new Callable() { + TestObserver to = Maybe.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { @@ -399,9 +398,9 @@ public void accept(Object d) throws Exception { public void doubleOnSubscribe() { List errors = TestHelper.trackPluginErrors(); try { - Maybe.using(new Callable() { + Maybe.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { @@ -442,9 +441,9 @@ public void successDisposeRace() { final PublishSubject ps = PublishSubject.create(); - final TestObserver to = Maybe.using(new Callable() { + final TestObserver to = Maybe.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { @@ -485,9 +484,9 @@ public void errorDisposeRace() { final PublishSubject ps = PublishSubject.create(); - final TestObserver to = Maybe.using(new Callable() { + final TestObserver to = Maybe.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { @@ -528,9 +527,9 @@ public void emptyDisposeRace() { final PublishSubject ps = PublishSubject.create(); - final TestObserver to = Maybe.using(new Callable() { + final TestObserver to = Maybe.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableBufferTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableBufferTest.java index 66a4e24dc0..a69f9998e9 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableBufferTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableBufferTest.java @@ -254,9 +254,9 @@ public void subscribe(Observer observer) { } }); - Callable> closer = new Callable>() { + Supplier> closer = new Supplier>() { @Override - public Observable call() { + public Observable get() { return Observable.unsafeCreate(new ObservableSource() { @Override public void subscribe(Observer observer) { @@ -833,9 +833,9 @@ static HashSet set(Integer... values) { @Test public void bufferIntoCustomCollection() { Observable.just(1, 1, 2, 2, 3, 3, 4, 4) - .buffer(3, new Callable>() { + .buffer(3, new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { return new HashSet(); } }) @@ -847,9 +847,9 @@ public Collection call() throws Exception { @Test public void bufferSkipIntoCustomCollection() { Observable.just(1, 1, 2, 2, 3, 3, 4, 4) - .buffer(3, 3, new Callable>() { + .buffer(3, 3, new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { return new HashSet(); } }) @@ -861,9 +861,9 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void supplierThrows() { Observable.just(1) - .buffer(1, TimeUnit.SECONDS, Schedulers.single(), Integer.MAX_VALUE, new Callable>() { + .buffer(1, TimeUnit.SECONDS, Schedulers.single(), Integer.MAX_VALUE, new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { throw new TestException(); } }, false) @@ -875,9 +875,9 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void supplierThrows2() { Observable.just(1) - .buffer(1, TimeUnit.SECONDS, Schedulers.single(), 10, new Callable>() { + .buffer(1, TimeUnit.SECONDS, Schedulers.single(), 10, new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { throw new TestException(); } }, false) @@ -889,9 +889,9 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void supplierThrows3() { Observable.just(1) - .buffer(2, 1, TimeUnit.SECONDS, Schedulers.single(), new Callable>() { + .buffer(2, 1, TimeUnit.SECONDS, Schedulers.single(), new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { throw new TestException(); } }) @@ -903,10 +903,10 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void supplierThrows4() { Observable.never() - .buffer(1, TimeUnit.MILLISECONDS, Schedulers.single(), Integer.MAX_VALUE, new Callable>() { + .buffer(1, TimeUnit.MILLISECONDS, Schedulers.single(), Integer.MAX_VALUE, new Supplier>() { int count; @Override - public Collection call() throws Exception { + public Collection get() throws Exception { if (count++ == 1) { throw new TestException(); } else { @@ -923,10 +923,10 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void supplierThrows5() { Observable.never() - .buffer(1, TimeUnit.MILLISECONDS, Schedulers.single(), 10, new Callable>() { + .buffer(1, TimeUnit.MILLISECONDS, Schedulers.single(), 10, new Supplier>() { int count; @Override - public Collection call() throws Exception { + public Collection get() throws Exception { if (count++ == 1) { throw new TestException(); } else { @@ -943,10 +943,10 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void supplierThrows6() { Observable.never() - .buffer(2, 1, TimeUnit.MILLISECONDS, Schedulers.single(), new Callable>() { + .buffer(2, 1, TimeUnit.MILLISECONDS, Schedulers.single(), new Supplier>() { int count; @Override - public Collection call() throws Exception { + public Collection get() throws Exception { if (count++ == 1) { throw new TestException(); } else { @@ -963,10 +963,10 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void supplierReturnsNull() { Observable.never() - .buffer(1, TimeUnit.MILLISECONDS, Schedulers.single(), Integer.MAX_VALUE, new Callable>() { + .buffer(1, TimeUnit.MILLISECONDS, Schedulers.single(), Integer.MAX_VALUE, new Supplier>() { int count; @Override - public Collection call() throws Exception { + public Collection get() throws Exception { if (count++ == 1) { return null; } else { @@ -983,10 +983,10 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void supplierReturnsNull2() { Observable.never() - .buffer(1, TimeUnit.MILLISECONDS, Schedulers.single(), 10, new Callable>() { + .buffer(1, TimeUnit.MILLISECONDS, Schedulers.single(), 10, new Supplier>() { int count; @Override - public Collection call() throws Exception { + public Collection get() throws Exception { if (count++ == 1) { return null; } else { @@ -1003,10 +1003,10 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void supplierReturnsNull3() { Observable.never() - .buffer(2, 1, TimeUnit.MILLISECONDS, Schedulers.single(), new Callable>() { + .buffer(2, 1, TimeUnit.MILLISECONDS, Schedulers.single(), new Supplier>() { int count; @Override - public Collection call() throws Exception { + public Collection get() throws Exception { if (count++ == 1) { return null; } else { @@ -1023,9 +1023,9 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void boundaryBufferSupplierThrows() { Observable.never() - .buffer(Functions.justCallable(Observable.never()), new Callable>() { + .buffer(Functions.justSupplier(Observable.never()), new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { throw new TestException(); } }) @@ -1037,14 +1037,14 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void boundaryBoundarySupplierThrows() { Observable.never() - .buffer(new Callable>() { + .buffer(new Supplier>() { @Override - public ObservableSource call() throws Exception { + public ObservableSource get() throws Exception { throw new TestException(); } - }, new Callable>() { + }, new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { return new ArrayList(); } }) @@ -1056,10 +1056,10 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void boundaryBufferSupplierThrows2() { Observable.never() - .buffer(Functions.justCallable(Observable.timer(1, TimeUnit.MILLISECONDS)), new Callable>() { + .buffer(Functions.justSupplier(Observable.timer(1, TimeUnit.MILLISECONDS)), new Supplier>() { int count; @Override - public Collection call() throws Exception { + public Collection get() throws Exception { if (count++ == 1) { throw new TestException(); } else { @@ -1076,10 +1076,10 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void boundaryBufferSupplierReturnsNull() { Observable.never() - .buffer(Functions.justCallable(Observable.timer(1, TimeUnit.MILLISECONDS)), new Callable>() { + .buffer(Functions.justSupplier(Observable.timer(1, TimeUnit.MILLISECONDS)), new Supplier>() { int count; @Override - public Collection call() throws Exception { + public Collection get() throws Exception { if (count++ == 1) { return null; } else { @@ -1096,18 +1096,18 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void boundaryBoundarySupplierThrows2() { Observable.never() - .buffer(new Callable>() { + .buffer(new Supplier>() { int count; @Override - public ObservableSource call() throws Exception { + public ObservableSource get() throws Exception { if (count++ == 1) { throw new TestException(); } return Observable.timer(1, TimeUnit.MILLISECONDS); } - }, new Callable>() { + }, new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { return new ArrayList(); } }) @@ -1121,9 +1121,9 @@ public void boundaryCancel() { PublishSubject ps = PublishSubject.create(); TestObserver> to = ps - .buffer(Functions.justCallable(Observable.never()), new Callable>() { + .buffer(Functions.justSupplier(Observable.never()), new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { return new ArrayList(); } }) @@ -1140,18 +1140,18 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void boundaryBoundarySupplierReturnsNull() { Observable.never() - .buffer(new Callable>() { + .buffer(new Supplier>() { int count; @Override - public ObservableSource call() throws Exception { + public ObservableSource get() throws Exception { if (count++ == 1) { return null; } return Observable.timer(1, TimeUnit.MILLISECONDS); } - }, new Callable>() { + }, new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { return new ArrayList(); } }) @@ -1164,18 +1164,18 @@ public Collection call() throws Exception { @SuppressWarnings("unchecked") public void boundaryBoundarySupplierReturnsNull2() { Observable.never() - .buffer(new Callable>() { + .buffer(new Supplier>() { int count; @Override - public ObservableSource call() throws Exception { + public ObservableSource get() throws Exception { if (count++ == 1) { return null; } return Observable.empty(); } - }, new Callable>() { + }, new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { return new ArrayList(); } }) @@ -1190,9 +1190,9 @@ public void boundaryMainError() { PublishSubject ps = PublishSubject.create(); TestObserver> to = ps - .buffer(Functions.justCallable(Observable.never()), new Callable>() { + .buffer(Functions.justSupplier(Observable.never()), new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { return new ArrayList(); } }) @@ -1209,9 +1209,9 @@ public void boundaryBoundaryError() { PublishSubject ps = PublishSubject.create(); TestObserver> to = ps - .buffer(Functions.justCallable(Observable.error(new TestException())), new Callable>() { + .buffer(Functions.justSupplier(Observable.error(new TestException())), new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { return new ArrayList(); } }) @@ -1241,7 +1241,7 @@ public void dispose() { TestHelper.checkDisposed(PublishSubject.create().buffer(Observable.never())); - TestHelper.checkDisposed(PublishSubject.create().buffer(Functions.justCallable(Observable.never()))); + TestHelper.checkDisposed(PublishSubject.create().buffer(Functions.justSupplier(Observable.never()))); TestHelper.checkDisposed(PublishSubject.create().buffer(Observable.never(), Functions.justFunction(Observable.never()))); } @@ -1259,10 +1259,10 @@ public void restartTimer() { @Test public void bufferSupplierCrash2() { Observable.range(1, 2) - .buffer(1, new Callable>() { + .buffer(1, new Supplier>() { int calls; @Override - public List call() throws Exception { + public List get() throws Exception { if (++calls == 2) { throw new TestException(); } @@ -1277,10 +1277,10 @@ public List call() throws Exception { @Test public void bufferSkipSupplierCrash2() { Observable.range(1, 2) - .buffer(2, 1, new Callable>() { + .buffer(2, 1, new Supplier>() { int calls; @Override - public List call() throws Exception { + public List get() throws Exception { if (++calls == 2) { throw new TestException(); } @@ -1377,10 +1377,10 @@ public void bufferTimedExactSupplierCrash() { PublishSubject ps = PublishSubject.create(); TestObserver> to = ps - .buffer(1, TimeUnit.MILLISECONDS, scheduler, 1, new Callable>() { + .buffer(1, TimeUnit.MILLISECONDS, scheduler, 1, new Supplier>() { int calls; @Override - public List call() throws Exception { + public List get() throws Exception { if (++calls == 2) { throw new TestException(); } @@ -1830,10 +1830,10 @@ public void bufferExactBoundarySecondBufferCrash() { PublishSubject ps = PublishSubject.create(); PublishSubject b = PublishSubject.create(); - TestObserver> to = ps.buffer(b, new Callable>() { + TestObserver> to = ps.buffer(b, new Supplier>() { int calls; @Override - public List call() throws Exception { + public List get() throws Exception { if (++calls == 2) { throw new TestException(); } @@ -1880,7 +1880,7 @@ public void bufferBoundaryErrorTwice() { List errors = TestHelper.trackPluginErrors(); try { BehaviorSubject.createDefault(1) - .buffer(Functions.justCallable(new Observable() { + .buffer(Functions.justSupplier(new Observable() { @Override protected void subscribeActual(Observer observer) { observer.onSubscribe(Disposables.empty()); @@ -1904,8 +1904,8 @@ public void bufferBoundarySupplierDisposed() { TestObserver> to = new TestObserver>(); BufferBoundarySupplierObserver, Integer> sub = new BufferBoundarySupplierObserver, Integer>( - to, Functions.justCallable((List)new ArrayList()), - Functions.justCallable(Observable.never()) + to, Functions.justSupplier((List)new ArrayList()), + Functions.justSupplier(Observable.never()) ); Disposable bs = Disposables.empty(); @@ -1933,8 +1933,8 @@ public void bufferBoundarySupplierBufferAlreadyCleared() { TestObserver> to = new TestObserver>(); BufferBoundarySupplierObserver, Integer> sub = new BufferBoundarySupplierObserver, Integer>( - to, Functions.justCallable((List)new ArrayList()), - Functions.justCallable(Observable.never()) + to, Functions.justSupplier((List)new ArrayList()), + Functions.justSupplier(Observable.never()) ); Disposable bs = Disposables.empty(); @@ -1981,7 +1981,7 @@ public void timedInternalState() { TestObserver> to = new TestObserver>(); BufferExactUnboundedObserver> sub = new BufferExactUnboundedObserver>( - to, Functions.justCallable((List)new ArrayList()), 1, TimeUnit.SECONDS, sch); + to, Functions.justSupplier((List)new ArrayList()), 1, TimeUnit.SECONDS, sch); sub.onSubscribe(Disposables.empty()); @@ -2031,7 +2031,7 @@ public void timedSkipInternalState() { TestObserver> to = new TestObserver>(); BufferSkipBoundedObserver> sub = new BufferSkipBoundedObserver>( - to, Functions.justCallable((List)new ArrayList()), 1, 1, TimeUnit.SECONDS, sch.createWorker()); + to, Functions.justSupplier((List)new ArrayList()), 1, 1, TimeUnit.SECONDS, sch.createWorker()); sub.onSubscribe(Disposables.empty()); @@ -2050,10 +2050,10 @@ public void timedSkipCancelWhenSecondBuffer() { final TestObserver> to = new TestObserver>(); BufferSkipBoundedObserver> sub = new BufferSkipBoundedObserver>( - to, new Callable>() { + to, new Supplier>() { int calls; @Override - public List call() throws Exception { + public List get() throws Exception { if (++calls == 2) { to.cancel(); } @@ -2076,7 +2076,7 @@ public void timedSizeBufferAlreadyCleared() { BufferExactBoundedObserver> sub = new BufferExactBoundedObserver>( - to, Functions.justCallable((List)new ArrayList()), + to, Functions.justSupplier((List)new ArrayList()), 1, TimeUnit.SECONDS, 1, false, sch.createWorker()) ; @@ -2118,7 +2118,7 @@ public void bufferExactState() { TestObserver> to = new TestObserver>(); BufferExactObserver> sub = new BufferExactObserver>( - to, 1, Functions.justCallable((List)new ArrayList()) + to, 1, Functions.justSupplier((List)new ArrayList()) ); sub.onComplete(); @@ -2140,9 +2140,9 @@ public ObservableSource> apply(Observable o) @Test public void bufferExactFailingSupplier() { Observable.empty() - .buffer(1, TimeUnit.SECONDS, Schedulers.computation(), 10, new Callable>() { + .buffer(1, TimeUnit.SECONDS, Schedulers.computation(), 10, new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { throw new TestException(); } }, false) diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableCacheTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableCacheTest.java index 989206f156..033c06d644 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableCacheTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableCacheTest.java @@ -107,7 +107,7 @@ public void accept(String v) { } @Test - public void testUnsubscribeSource() throws Exception { + public void testUnsubscribeSource() throws Throwable { Action unsubscribe = mock(Action.class); Observable o = Observable.just(1).doOnDispose(unsubscribe).cache(); o.subscribe(); diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableCollectTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableCollectTest.java index c970391047..4c7b85e6ee 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableCollectTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableCollectTest.java @@ -32,9 +32,9 @@ public final class ObservableCollectTest { @Test public void testCollectToListObservable() { Observable> o = Observable.just(1, 2, 3) - .collect(new Callable>() { + .collect(new Supplier>() { @Override - public List call() { + public List get() { return new ArrayList(); } }, new BiConsumer, Integer>() { @@ -62,9 +62,9 @@ public void accept(List list, Integer v) { @Test public void testCollectToStringObservable() { - String value = Observable.just(1, 2, 3).collect(new Callable() { + String value = Observable.just(1, 2, 3).collect(new Supplier() { @Override - public StringBuilder call() { + public StringBuilder get() { return new StringBuilder(); } }, @@ -90,7 +90,7 @@ public void testCollectorFailureDoesNotResultInTwoErrorEmissionsObservable() { final RuntimeException e2 = new RuntimeException(); Burst.items(1).error(e2) // - .collect(callableListCreator(), biConsumerThrows(e1)) // + .collect(supplierListCreator(), biConsumerThrows(e1)) // .toObservable() .test() // .assertError(e1) // @@ -107,7 +107,7 @@ public void testCollectorFailureDoesNotResultInTwoErrorEmissionsObservable() { public void testCollectorFailureDoesNotResultInErrorAndCompletedEmissionsObservable() { final RuntimeException e = new RuntimeException(); Burst.item(1).create() // - .collect(callableListCreator(), biConsumerThrows(e)) // + .collect(supplierListCreator(), biConsumerThrows(e)) // .toObservable() .test() // .assertError(e) // @@ -133,7 +133,7 @@ public void accept(Object o, Integer t) { } }; Burst.items(1, 2).create() // - .collect(callableListCreator(), throwOnFirstOnly)// + .collect(supplierListCreator(), throwOnFirstOnly)// .test() // .assertError(e) // .assertNoValues() // @@ -158,9 +158,9 @@ public void accept(HashSet s, Integer v) throws Exception { @Test public void testCollectToList() { Single> o = Observable.just(1, 2, 3) - .collect(new Callable>() { + .collect(new Supplier>() { @Override - public List call() { + public List get() { return new ArrayList(); } }, new BiConsumer, Integer>() { @@ -188,9 +188,9 @@ public void accept(List list, Integer v) { @Test public void testCollectToString() { - String value = Observable.just(1, 2, 3).collect(new Callable() { + String value = Observable.just(1, 2, 3).collect(new Supplier() { @Override - public StringBuilder call() { + public StringBuilder get() { return new StringBuilder(); } }, @@ -216,7 +216,7 @@ public void testCollectorFailureDoesNotResultInTwoErrorEmissions() { final RuntimeException e2 = new RuntimeException(); Burst.items(1).error(e2) // - .collect(callableListCreator(), biConsumerThrows(e1)) // + .collect(supplierListCreator(), biConsumerThrows(e1)) // .test() // .assertError(e1) // .assertNotComplete(); @@ -232,7 +232,7 @@ public void testCollectorFailureDoesNotResultInTwoErrorEmissions() { public void testCollectorFailureDoesNotResultInErrorAndCompletedEmissions() { final RuntimeException e = new RuntimeException(); Burst.item(1).create() // - .collect(callableListCreator(), biConsumerThrows(e)) // + .collect(supplierListCreator(), biConsumerThrows(e)) // .test() // .assertError(e) // .assertNotComplete(); @@ -257,7 +257,7 @@ public void accept(Object o, Integer t) { } }; Burst.items(1, 2).create() // - .collect(callableListCreator(), throwOnFirstOnly)// + .collect(supplierListCreator(), throwOnFirstOnly)// .test() // .assertError(e) // .assertNoValues() // @@ -281,9 +281,9 @@ public void accept(HashSet s, Integer v) throws Exception { @Test public void dispose() { - TestHelper.checkDisposed(Observable.range(1, 3).collect(new Callable>() { + TestHelper.checkDisposed(Observable.range(1, 3).collect(new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { return new ArrayList(); } }, new BiConsumer, Integer>() { @@ -293,9 +293,9 @@ public void accept(List a, Integer b) throws Exception { } })); - TestHelper.checkDisposed(Observable.range(1, 3).collect(new Callable>() { + TestHelper.checkDisposed(Observable.range(1, 3).collect(new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { return new ArrayList(); } }, new BiConsumer, Integer>() { @@ -311,9 +311,9 @@ public void doubleOnSubscribe() { TestHelper.checkDoubleOnSubscribeObservableToSingle(new Function, SingleSource>>() { @Override public SingleSource> apply(Observable o) throws Exception { - return o.collect(new Callable>() { + return o.collect(new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { return new ArrayList(); } }, new BiConsumer, Integer>() { @@ -328,9 +328,9 @@ public void accept(List a, Integer b) throws Exception { TestHelper.checkDoubleOnSubscribeObservable(new Function, ObservableSource>>() { @Override public ObservableSource> apply(Observable o) throws Exception { - return o.collect(new Callable>() { + return o.collect(new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { return new ArrayList(); } }, new BiConsumer, Integer>() { @@ -348,9 +348,9 @@ public void badSource() { TestHelper.checkBadSourceObservable(new Function, Object>() { @Override public Object apply(Observable o) throws Exception { - return o.collect(new Callable>() { + return o.collect(new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { return new ArrayList(); } }, new BiConsumer, Integer>() { diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableDeferTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableDeferTest.java index 47ca034628..6575dd6033 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableDeferTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableDeferTest.java @@ -13,14 +13,14 @@ package io.reactivex.internal.operators.observable; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; -import java.util.concurrent.Callable; - import org.junit.Test; import io.reactivex.*; import io.reactivex.exceptions.TestException; +import io.reactivex.functions.Supplier; @SuppressWarnings("unchecked") public class ObservableDeferTest { @@ -28,11 +28,11 @@ public class ObservableDeferTest { @Test public void testDefer() throws Throwable { - Callable> factory = mock(Callable.class); + Supplier> factory = mock(Supplier.class); Observable firstObservable = Observable.just("one", "two"); Observable secondObservable = Observable.just("three", "four"); - when(factory.call()).thenReturn(firstObservable, secondObservable); + when(factory.get()).thenReturn(firstObservable, secondObservable); Observable deferred = Observable.defer(factory); @@ -41,7 +41,7 @@ public void testDefer() throws Throwable { Observer firstObserver = TestHelper.mockObserver(); deferred.subscribe(firstObserver); - verify(factory, times(1)).call(); + verify(factory, times(1)).get(); verify(firstObserver, times(1)).onNext("one"); verify(firstObserver, times(1)).onNext("two"); verify(firstObserver, times(0)).onNext("three"); @@ -51,7 +51,7 @@ public void testDefer() throws Throwable { Observer secondObserver = TestHelper.mockObserver(); deferred.subscribe(secondObserver); - verify(factory, times(2)).call(); + verify(factory, times(2)).get(); verify(secondObserver, times(0)).onNext("one"); verify(secondObserver, times(0)).onNext("two"); verify(secondObserver, times(1)).onNext("three"); @@ -61,10 +61,10 @@ public void testDefer() throws Throwable { } @Test - public void testDeferFunctionThrows() throws Exception { - Callable> factory = mock(Callable.class); + public void testDeferFunctionThrows() throws Throwable { + Supplier> factory = mock(Supplier.class); - when(factory.call()).thenThrow(new TestException()); + when(factory.get()).thenThrow(new TestException()); Observable result = Observable.defer(factory); diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableDelayTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableDelayTest.java index 1088f2abc1..28f89d37cc 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableDelayTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableDelayTest.java @@ -368,9 +368,9 @@ public Observable apply(Integer t1) { public void testDelayWithObservableSubscriptionNormal() { PublishSubject source = PublishSubject.create(); final PublishSubject delay = PublishSubject.create(); - Callable> subFunc = new Callable>() { + Supplier> subFunc = new Supplier>() { @Override - public Observable call() { + public Observable get() { return delay; } }; @@ -403,9 +403,9 @@ public Observable apply(Integer t1) { public void testDelayWithObservableSubscriptionFunctionThrows() { PublishSubject source = PublishSubject.create(); final PublishSubject delay = PublishSubject.create(); - Callable> subFunc = new Callable>() { + Supplier> subFunc = new Supplier>() { @Override - public Observable call() { + public Observable get() { throw new TestException(); } }; @@ -437,9 +437,9 @@ public Observable apply(Integer t1) { public void testDelayWithObservableSubscriptionThrows() { PublishSubject source = PublishSubject.create(); final PublishSubject delay = PublishSubject.create(); - Callable> subFunc = new Callable>() { + Supplier> subFunc = new Supplier>() { @Override - public Observable call() { + public Observable get() { return delay; } }; @@ -497,9 +497,9 @@ public void testDelayWithObservableSubscriptionRunCompletion() { PublishSubject source = PublishSubject.create(); final PublishSubject sdelay = PublishSubject.create(); final PublishSubject delay = PublishSubject.create(); - Callable> subFunc = new Callable>() { + Supplier> subFunc = new Supplier>() { @Override - public Observable call() { + public Observable get() { return sdelay; } }; diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableDistinctTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableDistinctTest.java index 8114d64f9a..55a86ecb77 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableDistinctTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableDistinctTest.java @@ -18,7 +18,6 @@ import static org.mockito.Mockito.*; import java.util.*; -import java.util.concurrent.Callable; import org.junit.*; import org.mockito.InOrder; @@ -28,7 +27,7 @@ import io.reactivex.TestHelper; import io.reactivex.disposables.*; import io.reactivex.exceptions.TestException; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; import io.reactivex.internal.functions.Functions; import io.reactivex.internal.fuseable.*; import io.reactivex.observers.*; @@ -203,9 +202,9 @@ public void onComplete() { @Test public void collectionSupplierThrows() { Observable.just(1) - .distinct(Functions.identity(), new Callable>() { + .distinct(Functions.identity(), new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { throw new TestException(); } }) @@ -216,9 +215,9 @@ public Collection call() throws Exception { @Test public void collectionSupplierIsNull() { Observable.just(1) - .distinct(Functions.identity(), new Callable>() { + .distinct(Functions.identity(), new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { return null; } }) diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableFlatMapTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableFlatMapTest.java index 960722060a..17c5a3ba3e 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableFlatMapTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableFlatMapTest.java @@ -162,11 +162,11 @@ public R apply(T t1) { }; } - Callable just0(final R value) { - return new Callable() { + Supplier just0(final R value) { + return new Supplier() { @Override - public R call() { + public R get() { return value; } }; @@ -219,10 +219,10 @@ Observable. error(new RuntimeException("Forced failure!")) verify(o, never()).onError(any(Throwable.class)); } - Callable funcThrow0(R r) { - return new Callable() { + Supplier funcThrow0(R r) { + return new Supplier() { @Override - public R call() { + public R get() { throw new TestException(); } }; diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableFromTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableFromTest.java index 586480cc5b..61d459fa43 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableFromTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableFromTest.java @@ -57,7 +57,7 @@ public void fromArrayEmpty() { @Test public void fromArraySingle() { - assertTrue(Observable.fromArray(1) instanceof ScalarCallable); + assertTrue(Observable.fromArray(1) instanceof ScalarSupplier); } @Test diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableGenerateTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableGenerateTest.java index 467f9ebefa..94a5fa5adc 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableGenerateTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableGenerateTest.java @@ -13,10 +13,10 @@ package io.reactivex.internal.operators.observable; +import static org.junit.Assert.assertEquals; + import java.util.List; -import java.util.concurrent.Callable; -import static org.junit.Assert.*; import org.junit.Test; import io.reactivex.*; @@ -29,9 +29,9 @@ public class ObservableGenerateTest { @Test public void statefulBiconsumer() { - Observable.generate(new Callable() { + Observable.generate(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 10; } }, new BiConsumer>() { @@ -52,9 +52,9 @@ public void accept(Object d) throws Exception { @Test public void stateSupplierThrows() { - Observable.generate(new Callable() { + Observable.generate(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { throw new TestException(); } }, new BiConsumer>() { @@ -69,9 +69,9 @@ public void accept(Object s, Emitter e) throws Exception { @Test public void generatorThrows() { - Observable.generate(new Callable() { + Observable.generate(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new BiConsumer>() { @@ -88,9 +88,9 @@ public void accept(Object s, Emitter e) throws Exception { public void disposerThrows() { List errors = TestHelper.trackPluginErrors(); try { - Observable.generate(new Callable() { + Observable.generate(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new BiConsumer>() { @@ -115,9 +115,9 @@ public void accept(Object d) throws Exception { @Test public void dispose() { - TestHelper.checkDisposed(Observable.generate(new Callable() { + TestHelper.checkDisposed(Observable.generate(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new BiConsumer>() { @@ -131,7 +131,7 @@ public void accept(Object s, Emitter e) throws Exception { @Test public void nullError() { final int[] call = { 0 }; - Observable.generate(Functions.justCallable(1), + Observable.generate(Functions.justSupplier(1), new BiConsumer>() { @Override public void accept(Integer s, Emitter e) throws Exception { diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableGroupJoinTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableGroupJoinTest.java index 3f902cb4a4..03d801f4d8 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableGroupJoinTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableGroupJoinTest.java @@ -70,7 +70,7 @@ public Observable apply(T t1) { public Observable apply(final Integer leftValue, Observable rightValues) { return rightValues.map(new Function() { @Override - public Integer apply(Integer rightValue) throws Exception { + public Integer apply(Integer rightValue) throws Throwable { return add.apply(leftValue, rightValue); } }); diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableMapNotificationTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableMapNotificationTest.java index 748078fd02..78b794e237 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableMapNotificationTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableMapNotificationTest.java @@ -13,14 +13,12 @@ package io.reactivex.internal.operators.observable; -import java.util.concurrent.Callable; - import org.junit.Test; import io.reactivex.*; import io.reactivex.disposables.Disposables; import io.reactivex.exceptions.*; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; import io.reactivex.internal.functions.Functions; import io.reactivex.internal.operators.observable.ObservableMapNotification.MapNotificationObserver; import io.reactivex.observers.TestObserver; @@ -43,9 +41,9 @@ public Observable apply(Throwable e) { return Observable.error(e); } }, - new Callable>() { + new Supplier>() { @Override - public Observable call() { + public Observable get() { return Observable.never(); } } @@ -66,7 +64,7 @@ protected void subscribeActual(Observer observer) { observer, Functions.justFunction(Observable.just(1)), Functions.justFunction(Observable.just(2)), - Functions.justCallable(Observable.just(3)) + Functions.justSupplier(Observable.just(3)) ); mn.onSubscribe(Disposables.empty()); } @@ -81,7 +79,7 @@ public ObservableSource apply(Observable o) throws Exception { return o.flatMap( Functions.justFunction(Observable.just(1)), Functions.justFunction(Observable.just(2)), - Functions.justCallable(Observable.just(3)) + Functions.justSupplier(Observable.just(3)) ); } }); @@ -97,7 +95,7 @@ public Observable apply(Throwable t) throws Exception { throw new TestException("Inner"); } }, - Functions.justCallable(Observable.just(3))) + Functions.justSupplier(Observable.just(3))) .test() .assertFailure(CompositeException.class); diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableReduceTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableReduceTest.java index cb6e61e8f6..b3f03f79ff 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableReduceTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableReduceTest.java @@ -18,7 +18,6 @@ import static org.mockito.Mockito.*; import java.util.List; -import java.util.concurrent.Callable; import org.junit.*; @@ -243,9 +242,9 @@ public void testBackpressureWithInitialValue() throws InterruptedException { @Test public void reduceWithSingle() { Observable.range(1, 5) - .reduceWith(new Callable() { + .reduceWith(new Supplier() { @Override - public Integer call() throws Exception { + public Integer get() throws Exception { return 0; } }, new BiFunction() { diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableRefCountTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableRefCountTest.java index 0f0d930d8d..7b3717773d 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableRefCountTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableRefCountTest.java @@ -527,9 +527,9 @@ public void accept(Disposable d) { .flatMap(new Function>() { @Override public Observable apply(Long t1) { - return Observable.defer(new Callable>() { + return Observable.defer(new Supplier>() { @Override - public Observable call() { + public Observable get() { return Observable.error(new Exception("Some exception")); } }); diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableReplayTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableReplayTest.java index 40d09f4f33..720596f4fa 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableReplayTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableReplayTest.java @@ -512,7 +512,7 @@ public void run() { */ @SuppressWarnings("unchecked") @Test - public void testIssue2191_UnsubscribeSource() throws Exception { + public void testIssue2191_UnsubscribeSource() throws Throwable { // setup mocks Consumer sourceNext = mock(Consumer.class); Action sourceCompleted = mock(Action.class); @@ -562,7 +562,7 @@ public void testIssue2191_UnsubscribeSource() throws Exception { */ @SuppressWarnings("unchecked") @Test - public void testIssue2191_SchedulerUnsubscribe() throws Exception { + public void testIssue2191_SchedulerUnsubscribe() throws Throwable { // setup mocks Consumer sourceNext = mock(Consumer.class); Action sourceCompleted = mock(Action.class); @@ -615,7 +615,7 @@ public void testIssue2191_SchedulerUnsubscribe() throws Exception { */ @SuppressWarnings("unchecked") @Test - public void testIssue2191_SchedulerUnsubscribeOnError() throws Exception { + public void testIssue2191_SchedulerUnsubscribeOnError() throws Throwable { // setup mocks Consumer sourceNext = mock(Consumer.class); Action sourceCompleted = mock(Action.class); @@ -937,7 +937,7 @@ public void accept(String v) { } @Test - public void testUnsubscribeSource() throws Exception { + public void testUnsubscribeSource() throws Throwable { Action unsubscribe = mock(Action.class); Observable o = Observable.just(1).doOnDispose(unsubscribe).replay().autoConnect(); o.subscribe(); @@ -1555,7 +1555,7 @@ public Observable apply(Observable v) throws Exception { @Test public void replaySelectorConnectableReturnsNull() { - ObservableReplay.multicastSelector(Functions.justCallable((ConnectableObservable)null), Functions.justFunction(Observable.just(1))) + ObservableReplay.multicastSelector(Functions.justSupplier((ConnectableObservable)null), Functions.justFunction(Observable.just(1))) .test() .assertFailureAndMessage(NullPointerException.class, "The connectableFactory returned a null ConnectableObservable"); } diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableRetryTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableRetryTest.java index 0055449ef5..551a4e40a8 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableRetryTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableRetryTest.java @@ -349,7 +349,7 @@ public void testInfiniteRetry() { */ @SuppressWarnings("unchecked") @Test - public void testRetrySubscribesAgainAfterError() throws Exception { + public void testRetrySubscribesAgainAfterError() throws Throwable { // record emitted values with this action Consumer record = mock(Consumer.class); @@ -945,9 +945,9 @@ public void noCancelPreviousRetry() { final AtomicInteger times = new AtomicInteger(); - Observable source = Observable.defer(new Callable>() { + Observable source = Observable.defer(new Supplier>() { @Override - public ObservableSource call() throws Exception { + public ObservableSource get() throws Exception { if (times.getAndIncrement() < 4) { return Observable.error(new TestException()); } @@ -974,9 +974,9 @@ public void noCancelPreviousRetryWhile() { final AtomicInteger times = new AtomicInteger(); - Observable source = Observable.defer(new Callable>() { + Observable source = Observable.defer(new Supplier>() { @Override - public ObservableSource call() throws Exception { + public ObservableSource get() throws Exception { if (times.getAndIncrement() < 4) { return Observable.error(new TestException()); } @@ -1003,9 +1003,9 @@ public void noCancelPreviousRetryWhile2() { final AtomicInteger times = new AtomicInteger(); - Observable source = Observable.defer(new Callable>() { + Observable source = Observable.defer(new Supplier>() { @Override - public ObservableSource call() throws Exception { + public ObservableSource get() throws Exception { if (times.getAndIncrement() < 4) { return Observable.error(new TestException()); } @@ -1037,9 +1037,9 @@ public void noCancelPreviousRetryUntil() { final AtomicInteger times = new AtomicInteger(); - Observable source = Observable.defer(new Callable>() { + Observable source = Observable.defer(new Supplier>() { @Override - public ObservableSource call() throws Exception { + public ObservableSource get() throws Exception { if (times.getAndIncrement() < 4) { return Observable.error(new TestException()); } @@ -1071,9 +1071,9 @@ public void noCancelPreviousRepeatWhen() { final AtomicInteger times = new AtomicInteger(); - Observable source = Observable.defer(new Callable>() { + Observable source = Observable.defer(new Supplier>() { @Override - public ObservableSource call() throws Exception { + public ObservableSource get() throws Exception { if (times.get() < 4) { return Observable.error(new TestException()); } diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableScalarXMapTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableScalarXMapTest.java index 0ab9e8e914..195fe884d3 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableScalarXMapTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableScalarXMapTest.java @@ -15,13 +15,11 @@ import static org.junit.Assert.*; -import java.util.concurrent.Callable; - import org.junit.Test; import io.reactivex.*; import io.reactivex.exceptions.TestException; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; import io.reactivex.internal.disposables.EmptyDisposable; import io.reactivex.internal.operators.observable.ObservableScalarXMap.ScalarDisposable; import io.reactivex.observers.TestObserver; @@ -33,31 +31,31 @@ public void utilityClass() { TestHelper.checkUtilityClass(ObservableScalarXMap.class); } - static final class CallablePublisher implements ObservableSource, Callable { + static final class CallablePublisher implements ObservableSource, Supplier { @Override public void subscribe(Observer observer) { EmptyDisposable.error(new TestException(), observer); } @Override - public Integer call() throws Exception { + public Integer get() throws Exception { throw new TestException(); } } - static final class EmptyCallablePublisher implements ObservableSource, Callable { + static final class EmptyCallablePublisher implements ObservableSource, Supplier { @Override public void subscribe(Observer observer) { EmptyDisposable.complete(observer); } @Override - public Integer call() throws Exception { + public Integer get() throws Exception { return null; } } - static final class OneCallablePublisher implements ObservableSource, Callable { + static final class OneCallablePublisher implements ObservableSource, Supplier { @Override public void subscribe(Observer observer) { ScalarDisposable sd = new ScalarDisposable(observer, 1); @@ -66,7 +64,7 @@ public void subscribe(Observer observer) { } @Override - public Integer call() throws Exception { + public Integer get() throws Exception { return 1; } } diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableScanTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableScanTest.java index 35df1a462e..82e8679e54 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableScanTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableScanTest.java @@ -18,7 +18,6 @@ import static org.mockito.Mockito.*; import java.util.*; -import java.util.concurrent.Callable; import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.atomic.AtomicInteger; @@ -27,8 +26,7 @@ import io.reactivex.*; import io.reactivex.Observable; import io.reactivex.Observer; -import io.reactivex.disposables.Disposable; -import io.reactivex.disposables.Disposables; +import io.reactivex.disposables.*; import io.reactivex.exceptions.TestException; import io.reactivex.functions.*; import io.reactivex.observers.*; @@ -178,10 +176,10 @@ public void onNext(Integer t) { @Test public void testSeedFactory() { Observable> o = Observable.range(1, 10) - .collect(new Callable>() { + .collect(new Supplier>() { @Override - public List call() { + public List get() { return new ArrayList(); } diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableThrottleLatestTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableThrottleLatestTest.java index 059d516da1..c456c226fc 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableThrottleLatestTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableThrottleLatestTest.java @@ -181,7 +181,7 @@ public void normalEmitLast() { } @Test - public void take() throws Exception { + public void take() throws Throwable { Action onCancel = mock(Action.class); Observable.range(1, 5) diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableTimeoutWithSelectorTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableTimeoutWithSelectorTest.java index 3dad40f34a..28b11adc4c 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableTimeoutWithSelectorTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableTimeoutWithSelectorTest.java @@ -111,9 +111,9 @@ public Observable apply(Integer t1) { } }; - Callable> firstTimeoutFunc = new Callable>() { + Supplier> firstTimeoutFunc = new Supplier>() { @Override - public Observable call() { + public Observable get() { throw new TestException(); } }; diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableToListTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableToListTest.java index 18447143aa..51b3c79f57 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableToListTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableToListTest.java @@ -26,7 +26,7 @@ import io.reactivex.Observable; import io.reactivex.Observer; import io.reactivex.exceptions.TestException; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; public class ObservableToListTest { @@ -216,9 +216,9 @@ public void errorSingle() { @Test public void collectionSupplierThrows() { Observable.just(1) - .toList(new Callable>() { + .toList(new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { throw new TestException(); } }) @@ -231,9 +231,9 @@ public Collection call() throws Exception { @Test public void collectionSupplierReturnsNull() { Observable.just(1) - .toList(new Callable>() { + .toList(new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { return null; } }) @@ -247,9 +247,9 @@ public Collection call() throws Exception { @Test public void singleCollectionSupplierThrows() { Observable.just(1) - .toList(new Callable>() { + .toList(new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { throw new TestException(); } }) @@ -261,9 +261,9 @@ public Collection call() throws Exception { @Test public void singleCollectionSupplierReturnsNull() { Observable.just(1) - .toList(new Callable>() { + .toList(new Supplier>() { @Override - public Collection call() throws Exception { + public Collection get() throws Exception { return null; } }) diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableToMapTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableToMapTest.java index f9eb6e1634..6577881604 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableToMapTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableToMapTest.java @@ -13,17 +13,17 @@ package io.reactivex.internal.operators.observable; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; import java.util.*; -import java.util.concurrent.Callable; import org.junit.*; import io.reactivex.*; import io.reactivex.Observable; import io.reactivex.Observer; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; public class ObservableToMapTest { Observer objectObserver; @@ -149,9 +149,9 @@ public String apply(String t1) { public void testToMapWithFactoryObservable() { Observable source = Observable.just("a", "bb", "ccc", "dddd"); - Callable> mapFactory = new Callable>() { + Supplier> mapFactory = new Supplier>() { @Override - public Map call() { + public Map get() { return new LinkedHashMap() { private static final long serialVersionUID = -3296811238780863394L; @@ -193,9 +193,9 @@ public String apply(String v) { public void testToMapWithErrorThrowingFactoryObservable() { Observable source = Observable.just("a", "bb", "ccc", "dddd"); - Callable> mapFactory = new Callable>() { + Supplier> mapFactory = new Supplier>() { @Override - public Map call() { + public Map get() { throw new RuntimeException("Forced failure"); } }; @@ -322,9 +322,9 @@ public String apply(String t1) { public void testToMapWithFactory() { Observable source = Observable.just("a", "bb", "ccc", "dddd"); - Callable> mapFactory = new Callable>() { + Supplier> mapFactory = new Supplier>() { @Override - public Map call() { + public Map get() { return new LinkedHashMap() { private static final long serialVersionUID = -3296811238780863394L; @@ -365,9 +365,9 @@ public String apply(String v) { public void testToMapWithErrorThrowingFactory() { Observable source = Observable.just("a", "bb", "ccc", "dddd"); - Callable> mapFactory = new Callable>() { + Supplier> mapFactory = new Supplier>() { @Override - public Map call() { + public Map get() { throw new RuntimeException("Forced failure"); } }; diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableToMultimapTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableToMultimapTest.java index f762930fc1..e495c488e7 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableToMultimapTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableToMultimapTest.java @@ -13,17 +13,17 @@ package io.reactivex.internal.operators.observable; +import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.*; import java.util.*; -import java.util.concurrent.Callable; import org.junit.*; import io.reactivex.*; import io.reactivex.Observable; import io.reactivex.Observer; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; public class ObservableToMultimapTest { Observer objectObserver; @@ -86,9 +86,9 @@ public void testToMultimapWithValueSelectorObservable() { public void testToMultimapWithMapFactoryObservable() { Observable source = Observable.just("a", "b", "cc", "dd", "eee", "fff"); - Callable>> mapFactory = new Callable>>() { + Supplier>> mapFactory = new Supplier>>() { @Override - public Map> call() { + public Map> get() { return new LinkedHashMap>() { private static final long serialVersionUID = -2084477070717362859L; @@ -149,9 +149,9 @@ public String apply(String v) { return v; } }; - Callable>> mapSupplier = new Callable>>() { + Supplier>> mapSupplier = new Supplier>>() { @Override - public Map> call() { + public Map> get() { return new HashMap>(); } }; @@ -228,9 +228,9 @@ public String apply(String t1) { public void testToMultimapWithMapThrowingFactoryObservable() { Observable source = Observable.just("a", "b", "cc", "dd", "eee", "fff"); - Callable>> mapFactory = new Callable>>() { + Supplier>> mapFactory = new Supplier>>() { @Override - public Map> call() { + public Map> get() { throw new RuntimeException("Forced failure"); } }; @@ -275,9 +275,9 @@ public String apply(String v) { return v; } }; - Callable>> mapSupplier = new Callable>>() { + Supplier>> mapSupplier = new Supplier>>() { @Override - public Map> call() { + public Map> get() { return new HashMap>(); } }; @@ -332,9 +332,9 @@ public void testToMultimapWithValueSelector() { public void testToMultimapWithMapFactory() { Observable source = Observable.just("a", "b", "cc", "dd", "eee", "fff"); - Callable>> mapFactory = new Callable>>() { + Supplier>> mapFactory = new Supplier>>() { @Override - public Map> call() { + public Map> get() { return new LinkedHashMap>() { private static final long serialVersionUID = -2084477070717362859L; @@ -394,9 +394,9 @@ public String apply(String v) { return v; } }; - Callable>> mapSupplier = new Callable>>() { + Supplier>> mapSupplier = new Supplier>>() { @Override - public Map> call() { + public Map> get() { return new HashMap>(); } }; @@ -470,9 +470,9 @@ public String apply(String t1) { public void testToMultimapWithMapThrowingFactory() { Observable source = Observable.just("a", "b", "cc", "dd", "eee", "fff"); - Callable>> mapFactory = new Callable>>() { + Supplier>> mapFactory = new Supplier>>() { @Override - public Map> call() { + public Map> get() { throw new RuntimeException("Forced failure"); } }; @@ -516,9 +516,9 @@ public String apply(String v) { return v; } }; - Callable>> mapSupplier = new Callable>>() { + Supplier>> mapSupplier = new Supplier>>() { @Override - public Map> call() { + public Map> get() { return new HashMap>(); } }; diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableUsingTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableUsingTest.java index 02fd41ef54..22d7c13731 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableUsingTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableUsingTest.java @@ -17,7 +17,6 @@ import static org.mockito.Mockito.*; import java.util.*; -import java.util.concurrent.Callable; import org.junit.*; import org.mockito.InOrder; @@ -72,9 +71,9 @@ private void performTestUsing(boolean disposeEagerly) { final Resource resource = mock(Resource.class); when(resource.getTextFromWeb()).thenReturn("Hello world!"); - Callable resourceFactory = new Callable() { + Supplier resourceFactory = new Supplier() { @Override - public Resource call() { + public Resource get() { return resource; } }; @@ -114,9 +113,9 @@ public void testUsingWithSubscribingTwiceDisposeEagerly() { private void performTestUsingWithSubscribingTwice(boolean disposeEagerly) { // When subscribe is called, a new resource should be created. - Callable resourceFactory = new Callable() { + Supplier resourceFactory = new Supplier() { @Override - public Resource call() { + public Resource get() { return new Resource() { boolean first = true; @@ -176,9 +175,9 @@ public void testUsingWithResourceFactoryErrorDisposeEagerly() { } private void performTestUsingWithResourceFactoryError(boolean disposeEagerly) { - Callable resourceFactory = new Callable() { + Supplier resourceFactory = new Supplier() { @Override - public Disposable call() { + public Disposable get() { throw new TestException(); } }; @@ -206,9 +205,9 @@ public void testUsingWithObservableFactoryErrorDisposeEagerly() { private void performTestUsingWithObservableFactoryError(boolean disposeEagerly) { final Runnable unsubscribe = mock(Runnable.class); - Callable resourceFactory = new Callable() { + Supplier resourceFactory = new Supplier() { @Override - public Disposable call() { + public Disposable get() { return Disposables.fromRunnable(unsubscribe); } }; @@ -244,9 +243,9 @@ public void testUsingWithObservableFactoryErrorInOnSubscribeDisposeEagerly() { private void performTestUsingWithObservableFactoryErrorInOnSubscribe(boolean disposeEagerly) { final Runnable unsubscribe = mock(Runnable.class); - Callable resourceFactory = new Callable() { + Supplier resourceFactory = new Supplier() { @Override - public Disposable call() { + public Disposable get() { return Disposables.fromRunnable(unsubscribe); } }; @@ -279,7 +278,7 @@ public void subscribe(Observer t1) { @Test public void testUsingDisposesEagerlyBeforeCompletion() { final List events = new ArrayList(); - Callable resourceFactory = createResourceFactory(events); + Supplier resourceFactory = createResourceFactory(events); final Action completion = createOnCompletedAction(events); final Action unsub = createUnsubAction(events); @@ -306,7 +305,7 @@ public Observable apply(Resource resource) { @Test public void testUsingDoesNotDisposesEagerlyBeforeCompletion() { final List events = new ArrayList(); - Callable resourceFactory = createResourceFactory(events); + Supplier resourceFactory = createResourceFactory(events); final Action completion = createOnCompletedAction(events); final Action unsub = createUnsubAction(events); @@ -333,7 +332,7 @@ public Observable apply(Resource resource) { @Test public void testUsingDisposesEagerlyBeforeError() { final List events = new ArrayList(); - Callable resourceFactory = createResourceFactory(events); + Supplier resourceFactory = createResourceFactory(events); final Consumer onError = createOnErrorAction(events); final Action unsub = createUnsubAction(events); @@ -361,7 +360,7 @@ public Observable apply(Resource resource) { @Test public void testUsingDoesNotDisposesEagerlyBeforeError() { final List events = new ArrayList(); - final Callable resourceFactory = createResourceFactory(events); + final Supplier resourceFactory = createResourceFactory(events); final Consumer onError = createOnErrorAction(events); final Action unsub = createUnsubAction(events); @@ -403,10 +402,10 @@ public void accept(Throwable t) { }; } - private static Callable createResourceFactory(final List events) { - return new Callable() { + private static Supplier createResourceFactory(final List events) { + return new Supplier() { @Override - public Resource call() { + public Resource get() { return new Resource() { @Override @@ -435,9 +434,9 @@ public void run() { @Test public void dispose() { TestHelper.checkDisposed(Observable.using( - new Callable() { + new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, @@ -453,9 +452,9 @@ public ObservableSource apply(Object v) throws Exception { @Test public void supplierDisposerCrash() { - TestObserver to = Observable.using(new Callable() { + TestObserver to = Observable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { @@ -480,9 +479,9 @@ public void accept(Object e) throws Exception { @Test public void eagerOnErrorDisposerCrash() { - TestObserver to = Observable.using(new Callable() { + TestObserver to = Observable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { @@ -507,9 +506,9 @@ public void accept(Object e) throws Exception { @Test public void eagerOnCompleteDisposerCrash() { - Observable.using(new Callable() { + Observable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { @@ -531,9 +530,9 @@ public void accept(Object e) throws Exception { public void nonEagerDisposerCrash() { List errors = TestHelper.trackPluginErrors(); try { - Observable.using(new Callable() { + Observable.using(new Supplier() { @Override - public Object call() throws Exception { + public Object get() throws Exception { return 1; } }, new Function>() { @@ -558,7 +557,7 @@ public void accept(Object e) throws Exception { @Test public void sourceSupplierReturnsNull() { - Observable.using(Functions.justCallable(1), + Observable.using(Functions.justSupplier(1), Functions.justFunction((Observable)null), Functions.emptyConsumer()) .test() @@ -572,7 +571,7 @@ public void doubleOnSubscribe() { @Override public ObservableSource apply(Observable o) throws Exception { - return Observable.using(Functions.justCallable(1), Functions.justFunction(o), Functions.emptyConsumer()); + return Observable.using(Functions.justSupplier(1), Functions.justFunction(o), Functions.emptyConsumer()); } }); } @@ -581,7 +580,7 @@ public ObservableSource apply(Observable o) public void eagerDisposedOnComplete() { final TestObserver to = new TestObserver(); - Observable.using(Functions.justCallable(1), Functions.justFunction(new Observable() { + Observable.using(Functions.justSupplier(1), Functions.justFunction(new Observable() { @Override protected void subscribeActual(Observer observer) { observer.onSubscribe(Disposables.empty()); @@ -596,7 +595,7 @@ protected void subscribeActual(Observer observer) { public void eagerDisposedOnError() { final TestObserver to = new TestObserver(); - Observable.using(Functions.justCallable(1), Functions.justFunction(new Observable() { + Observable.using(Functions.justSupplier(1), Functions.justFunction(new Observable() { @Override protected void subscribeActual(Observer observer) { observer.onSubscribe(Disposables.empty()); diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableWindowWithObservableTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableWindowWithObservableTest.java index a82e876464..8215add86b 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableWindowWithObservableTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableWindowWithObservableTest.java @@ -18,7 +18,7 @@ import static org.mockito.Mockito.*; import java.util.*; -import java.util.concurrent.*; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.*; import org.junit.Test; @@ -28,7 +28,7 @@ import io.reactivex.Observer; import io.reactivex.disposables.*; import io.reactivex.exceptions.*; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; import io.reactivex.internal.functions.Functions; import io.reactivex.observers.*; import io.reactivex.plugins.RxJavaPlugins; @@ -270,9 +270,9 @@ public void onNext(Observable t) { super.onNext(t); } }; - source.window(new Callable>() { + source.window(new Supplier>() { @Override - public Observable call() { + public Observable get() { return Observable.never(); } }).subscribe(to); @@ -287,9 +287,9 @@ public Observable call() { @Test public void testWindowViaObservableNoUnsubscribe() { Observable source = Observable.range(1, 10); - Callable> boundary = new Callable>() { + Supplier> boundary = new Supplier>() { @Override - public Observable call() { + public Observable get() { return Observable.empty(); } }; @@ -306,9 +306,9 @@ public Observable call() { public void testBoundaryUnsubscribedOnMainCompletion() { PublishSubject source = PublishSubject.create(); final PublishSubject boundary = PublishSubject.create(); - Callable> boundaryFunc = new Callable>() { + Supplier> boundaryFunc = new Supplier>() { @Override - public Observable call() { + public Observable get() { return boundary; } }; @@ -333,9 +333,9 @@ public Observable call() { public void testMainUnsubscribedOnBoundaryCompletion() { PublishSubject source = PublishSubject.create(); final PublishSubject boundary = PublishSubject.create(); - Callable> boundaryFunc = new Callable>() { + Supplier> boundaryFunc = new Supplier>() { @Override - public Observable call() { + public Observable get() { return boundary; } }; @@ -360,9 +360,9 @@ public Observable call() { public void testChildUnsubscribed() { PublishSubject source = PublishSubject.create(); final PublishSubject boundary = PublishSubject.create(); - Callable> boundaryFunc = new Callable>() { + Supplier> boundaryFunc = new Supplier>() { @Override - public Observable call() { + public Observable get() { return boundary; } }; @@ -393,9 +393,9 @@ public void newBoundaryCalledAfterWindowClosed() { final AtomicInteger calls = new AtomicInteger(); PublishSubject source = PublishSubject.create(); final PublishSubject boundary = PublishSubject.create(); - Callable> boundaryFunc = new Callable>() { + Supplier> boundaryFunc = new Supplier>() { @Override - public Observable call() { + public Observable get() { calls.getAndIncrement(); return boundary; } @@ -434,7 +434,7 @@ public void boundaryDispose() { @Test public void boundaryDispose2() { - TestHelper.checkDisposed(Observable.never().window(Functions.justCallable(Observable.never()))); + TestHelper.checkDisposed(Observable.never().window(Functions.justSupplier(Observable.never()))); } @Test @@ -453,7 +453,7 @@ public void boundaryOnError() { @Test public void mainError() { Observable.error(new TestException()) - .window(Functions.justCallable(Observable.never())) + .window(Functions.justSupplier(Observable.never())) .test() .assertError(TestException.class); } @@ -475,7 +475,7 @@ public ObservableSource apply(Observable v) throws Exception { TestHelper.checkBadSourceObservable(new Function, Object>() { @Override public Object apply(Observable o) throws Exception { - return Observable.just(1).window(Functions.justCallable(o)).flatMap(new Function, ObservableSource>() { + return Observable.just(1).window(Functions.justSupplier(o)).flatMap(new Function, ObservableSource>() { @Override public ObservableSource apply(Observable v) throws Exception { return v; @@ -531,10 +531,10 @@ public void onNext(Integer t) { } }; - ps.window(new Callable>() { + ps.window(new Supplier>() { boolean once; @Override - public Observable call() throws Exception { + public Observable get() throws Exception { if (!once) { once = true; return BehaviorSubject.createDefault(1); @@ -577,7 +577,7 @@ public void badSourceCallable() { TestHelper.checkBadSourceObservable(new Function, Object>() { @Override public Object apply(Observable o) throws Exception { - return o.window(Functions.justCallable(Observable.never())).flatMap(new Function, ObservableSource>() { + return o.window(Functions.justSupplier(Observable.never())).flatMap(new Function, ObservableSource>() { @Override public ObservableSource apply(Observable v) throws Exception { return v; @@ -590,7 +590,7 @@ public ObservableSource apply(Observable v) throws Exception { @Test public void boundaryError() { BehaviorSubject.createDefault(1) - .window(Functions.justCallable(Observable.error(new TestException()))) + .window(Functions.justSupplier(Observable.error(new TestException()))) .test() .assertValueCount(1) .assertNotComplete() @@ -600,10 +600,10 @@ public void boundaryError() { @Test public void boundaryCallableCrashOnCall2() { BehaviorSubject.createDefault(1) - .window(new Callable>() { + .window(new Supplier>() { int calls; @Override - public Observable call() throws Exception { + public Observable get() throws Exception { if (++calls == 2) { throw new TestException(); } @@ -620,7 +620,7 @@ public void oneWindow() { PublishSubject ps = PublishSubject.create(); TestObserver> to = BehaviorSubject.createDefault(1) - .window(Functions.justCallable(ps)) + .window(Functions.justSupplier(ps)) .take(1) .test(); @@ -946,7 +946,7 @@ public void boundarySupplierDoubleOnSubscribe() { @Override public Observable> apply(Observable f) throws Exception { - return f.window(Functions.justCallable(Observable.never())).takeLast(1); + return f.window(Functions.justSupplier(Observable.never())).takeLast(1); } }); } @@ -956,7 +956,7 @@ public void selectorUpstreamDisposedWhenOutputsDisposed() { PublishSubject source = PublishSubject.create(); PublishSubject boundary = PublishSubject.create(); - TestObserver to = source.window(Functions.justCallable(boundary)) + TestObserver to = source.window(Functions.justSupplier(boundary)) .take(1) .flatMap(new Function, ObservableSource>() { @Override @@ -982,7 +982,7 @@ public void supplierMainAndBoundaryBothError() { final AtomicReference> ref = new AtomicReference>(); TestObserver> to = Observable.error(new TestException("main")) - .window(Functions.justCallable(new Observable() { + .window(Functions.justSupplier(new Observable() { @Override protected void subscribeActual(Observer observer) { observer.onSubscribe(Disposables.empty()); @@ -1022,7 +1022,7 @@ protected void subscribeActual(Observer observer) { refMain.set(observer); } } - .window(Functions.justCallable(new Observable() { + .window(Functions.justSupplier(new Observable() { @Override protected void subscribeActual(Observer observer) { observer.onSubscribe(Disposables.empty()); @@ -1072,7 +1072,7 @@ protected void subscribeActual(Observer observer) { refMain.set(observer); } } - .window(Functions.justCallable(new Observable() { + .window(Functions.justSupplier(new Observable() { @Override protected void subscribeActual(Observer observer) { observer.onSubscribe(Disposables.empty()); @@ -1115,7 +1115,7 @@ protected void subscribeActual(Observer observer) { refMain.set(observer); } } - .window(Functions.justCallable(new Observable() { + .window(Functions.justSupplier(new Observable() { @Override protected void subscribeActual(Observer observer) { observer.onSubscribe(Disposables.empty()); @@ -1147,7 +1147,7 @@ protected void subscribeActual(Observer observer) { refMain.set(observer); } } - .window(Functions.justCallable(new Observable() { + .window(Functions.justSupplier(new Observable() { @Override protected void subscribeActual(Observer observer) { final AtomicInteger counter = new AtomicInteger(); @@ -1207,10 +1207,10 @@ protected void subscribeActual(Observer observer) { refMain.set(observer); } } - .window(new Callable>() { + .window(new Supplier>() { int count; @Override - public ObservableSource call() throws Exception { + public ObservableSource get() throws Exception { if (++count > 1) { return Observable.never(); } diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableWindowWithStartEndObservableTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableWindowWithStartEndObservableTest.java index c4f7fa6409..1186667b98 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableWindowWithStartEndObservableTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableWindowWithStartEndObservableTest.java @@ -113,10 +113,10 @@ public void subscribe(Observer innerObserver) { } }); - Callable> closer = new Callable>() { + Supplier> closer = new Supplier>() { int calls; @Override - public Observable call() { + public Observable get() { return Observable.unsafeCreate(new ObservableSource() { @Override public void subscribe(Observer innerObserver) { diff --git a/src/test/java/io/reactivex/internal/operators/single/SingleDeferTest.java b/src/test/java/io/reactivex/internal/operators/single/SingleDeferTest.java index 01f0815a52..779b094345 100644 --- a/src/test/java/io/reactivex/internal/operators/single/SingleDeferTest.java +++ b/src/test/java/io/reactivex/internal/operators/single/SingleDeferTest.java @@ -13,21 +13,20 @@ package io.reactivex.internal.operators.single; -import java.util.concurrent.Callable; - import org.junit.Test; import io.reactivex.Single; +import io.reactivex.functions.Supplier; public class SingleDeferTest { @Test public void normal() { - Single s = Single.defer(new Callable>() { + Single s = Single.defer(new Supplier>() { int counter; @Override - public Single call() throws Exception { + public Single get() throws Exception { return Single.just(++counter); } }); diff --git a/src/test/java/io/reactivex/internal/operators/single/SingleErrorTest.java b/src/test/java/io/reactivex/internal/operators/single/SingleErrorTest.java index 8465f2900e..dc421d5e45 100644 --- a/src/test/java/io/reactivex/internal/operators/single/SingleErrorTest.java +++ b/src/test/java/io/reactivex/internal/operators/single/SingleErrorTest.java @@ -13,20 +13,19 @@ package io.reactivex.internal.operators.single; -import java.util.concurrent.Callable; - import org.junit.Test; import io.reactivex.Single; import io.reactivex.exceptions.TestException; +import io.reactivex.functions.Supplier; public class SingleErrorTest { @Test - public void errorCallableThrows() { - Single.error(new Callable() { + public void errorSupplierThrows() { + Single.error(new Supplier() { @Override - public Throwable call() throws Exception { + public Throwable get() throws Exception { throw new TestException(); } }) diff --git a/src/test/java/io/reactivex/internal/operators/single/SingleUsingTest.java b/src/test/java/io/reactivex/internal/operators/single/SingleUsingTest.java index f49c35144d..563da379df 100644 --- a/src/test/java/io/reactivex/internal/operators/single/SingleUsingTest.java +++ b/src/test/java/io/reactivex/internal/operators/single/SingleUsingTest.java @@ -16,7 +16,6 @@ import static org.junit.Assert.*; import java.util.List; -import java.util.concurrent.Callable; import org.junit.Test; @@ -61,9 +60,9 @@ public void accept(Disposable d) throws Exception { @Test public void resourceSupplierThrows() { - Single.using(new Callable() { + Single.using(new Supplier() { @Override - public Integer call() throws Exception { + public Integer get() throws Exception { throw new TestException(); } }, Functions.justFunction(Single.just(1)), Functions.emptyConsumer()) @@ -73,35 +72,35 @@ public Integer call() throws Exception { @Test public void normalEager() { - Single.using(Functions.justCallable(1), Functions.justFunction(Single.just(1)), Functions.emptyConsumer()) + Single.using(Functions.justSupplier(1), Functions.justFunction(Single.just(1)), Functions.emptyConsumer()) .test() .assertResult(1); } @Test public void normalNonEager() { - Single.using(Functions.justCallable(1), Functions.justFunction(Single.just(1)), Functions.emptyConsumer(), false) + Single.using(Functions.justSupplier(1), Functions.justFunction(Single.just(1)), Functions.emptyConsumer(), false) .test() .assertResult(1); } @Test public void errorEager() { - Single.using(Functions.justCallable(1), Functions.justFunction(Single.error(new TestException())), Functions.emptyConsumer()) + Single.using(Functions.justSupplier(1), Functions.justFunction(Single.error(new TestException())), Functions.emptyConsumer()) .test() .assertFailure(TestException.class); } @Test public void errorNonEager() { - Single.using(Functions.justCallable(1), Functions.justFunction(Single.error(new TestException())), Functions.emptyConsumer(), false) + Single.using(Functions.justSupplier(1), Functions.justFunction(Single.error(new TestException())), Functions.emptyConsumer(), false) .test() .assertFailure(TestException.class); } @Test public void eagerMapperThrowsDisposerThrows() { - TestObserver to = Single.using(Functions.justCallable(Disposables.empty()), mapperThrows, disposerThrows) + TestObserver to = Single.using(Functions.justSupplier(Disposables.empty()), mapperThrows, disposerThrows) .test() .assertFailure(CompositeException.class); @@ -116,7 +115,7 @@ public void noneagerMapperThrowsDisposerThrows() { List errors = TestHelper.trackPluginErrors(); try { - Single.using(Functions.justCallable(Disposables.empty()), mapperThrows, disposerThrows, false) + Single.using(Functions.justSupplier(Disposables.empty()), mapperThrows, disposerThrows, false) .test() .assertFailureAndMessage(TestException.class, "Mapper"); @@ -130,7 +129,7 @@ public void noneagerMapperThrowsDisposerThrows() { public void resourceDisposedIfMapperCrashes() { Disposable d = Disposables.empty(); - Single.using(Functions.justCallable(d), mapperThrows, disposer) + Single.using(Functions.justSupplier(d), mapperThrows, disposer) .test() .assertFailure(TestException.class); @@ -141,7 +140,7 @@ public void resourceDisposedIfMapperCrashes() { public void resourceDisposedIfMapperCrashesNonEager() { Disposable d = Disposables.empty(); - Single.using(Functions.justCallable(d), mapperThrows, disposer, false) + Single.using(Functions.justSupplier(d), mapperThrows, disposer, false) .test() .assertFailure(TestException.class); @@ -152,7 +151,7 @@ public void resourceDisposedIfMapperCrashesNonEager() { public void dispose() { Disposable d = Disposables.empty(); - Single.using(Functions.justCallable(d), mapper, disposer, false) + Single.using(Functions.justSupplier(d), mapper, disposer, false) .test(true); assertTrue(d.isDisposed()); @@ -160,7 +159,7 @@ public void dispose() { @Test public void disposerThrowsEager() { - Single.using(Functions.justCallable(Disposables.empty()), mapper, disposerThrows) + Single.using(Functions.justSupplier(Disposables.empty()), mapper, disposerThrows) .test() .assertFailure(TestException.class); } @@ -171,7 +170,7 @@ public void disposerThrowsNonEager() { List errors = TestHelper.trackPluginErrors(); try { - Single.using(Functions.justCallable(Disposables.empty()), mapper, disposerThrows, false) + Single.using(Functions.justSupplier(Disposables.empty()), mapper, disposerThrows, false) .test() .assertResult(1); TestHelper.assertUndeliverable(errors, 0, TestException.class, "Disposer"); @@ -182,7 +181,7 @@ public void disposerThrowsNonEager() { @Test public void errorAndDisposerThrowsEager() { - TestObserver to = Single.using(Functions.justCallable(Disposables.empty()), + TestObserver to = Single.using(Functions.justSupplier(Disposables.empty()), new Function>() { @Override public SingleSource apply(Disposable v) throws Exception { @@ -202,7 +201,7 @@ public void errorAndDisposerThrowsNonEager() { List errors = TestHelper.trackPluginErrors(); try { - Single.using(Functions.justCallable(Disposables.empty()), + Single.using(Functions.justSupplier(Disposables.empty()), new Function>() { @Override public SingleSource apply(Disposable v) throws Exception { @@ -224,7 +223,7 @@ public void successDisposeRace() { Disposable d = Disposables.empty(); - final TestObserver to = Single.using(Functions.justCallable(d), new Function>() { + final TestObserver to = Single.using(Functions.justSupplier(d), new Function>() { @Override public SingleSource apply(Disposable v) throws Exception { return pp.single(-99); @@ -258,7 +257,7 @@ public void doubleOnSubscribe() { List errors = TestHelper.trackPluginErrors(); try { - Single.using(Functions.justCallable(1), new Function>() { + Single.using(Functions.justSupplier(1), new Function>() { @Override public SingleSource apply(Integer v) throws Exception { return new Single() { @@ -299,7 +298,7 @@ public void errorDisposeRace() { Disposable d = Disposables.empty(); - final TestObserver to = Single.using(Functions.justCallable(d), new Function>() { + final TestObserver to = Single.using(Functions.justSupplier(d), new Function>() { @Override public SingleSource apply(Disposable v) throws Exception { return pp.single(-99); diff --git a/src/test/java/io/reactivex/internal/schedulers/SchedulerWhenTest.java b/src/test/java/io/reactivex/internal/schedulers/SchedulerWhenTest.java index bbf97be11d..380ea91f0a 100644 --- a/src/test/java/io/reactivex/internal/schedulers/SchedulerWhenTest.java +++ b/src/test/java/io/reactivex/internal/schedulers/SchedulerWhenTest.java @@ -17,7 +17,6 @@ import static java.util.concurrent.TimeUnit.SECONDS; import static org.junit.Assert.*; -import java.util.concurrent.Callable; import java.util.concurrent.atomic.AtomicInteger; import org.junit.Test; @@ -26,7 +25,7 @@ import io.reactivex.Scheduler.Worker; import io.reactivex.disposables.*; import io.reactivex.exceptions.TestException; -import io.reactivex.functions.Function; +import io.reactivex.functions.*; import io.reactivex.internal.schedulers.SchedulerWhen.*; import io.reactivex.observers.DisposableCompletableObserver; import io.reactivex.processors.PublishProcessor; @@ -164,9 +163,9 @@ private Flowable syncWork(final Scheduler sched) { return Flowable.range(1, 5).flatMap(new Function>() { @Override public Flowable apply(Integer t) { - return Flowable.defer(new Callable>() { + return Flowable.defer(new Supplier>() { @Override - public Flowable call() { + public Flowable get() { return Flowable.just(0l); } }).subscribeOn(sched); diff --git a/src/test/java/io/reactivex/internal/util/MiscUtilTest.java b/src/test/java/io/reactivex/internal/util/MiscUtilTest.java index 464262bce9..ae767ddde2 100644 --- a/src/test/java/io/reactivex/internal/util/MiscUtilTest.java +++ b/src/test/java/io/reactivex/internal/util/MiscUtilTest.java @@ -87,7 +87,7 @@ public boolean test(Integer t2) { } @Test - public void appendOnlyLinkedArrayListForEachWhileBi() throws Exception { + public void appendOnlyLinkedArrayListForEachWhileBi() throws Throwable { AppendOnlyLinkedArrayList list = new AppendOnlyLinkedArrayList(2); list.add(1); @@ -98,7 +98,7 @@ public void appendOnlyLinkedArrayListForEachWhileBi() throws Exception { list.forEachWhile(2, new BiPredicate() { @Override - public boolean test(Integer t1, Integer t2) throws Exception { + public boolean test(Integer t1, Integer t2) throws Throwable { out.add(t2); return t1.equals(t2); } @@ -192,7 +192,7 @@ public boolean test(Integer t2) { } @Test - public void appendOnlyLinkedArrayListForEachWhileBiPreGrow() throws Exception { + public void appendOnlyLinkedArrayListForEachWhileBiPreGrow() throws Throwable { AppendOnlyLinkedArrayList list = new AppendOnlyLinkedArrayList(12); list.add(1); @@ -203,7 +203,7 @@ public void appendOnlyLinkedArrayListForEachWhileBiPreGrow() throws Exception { list.forEachWhile(2, new BiPredicate() { @Override - public boolean test(Integer t1, Integer t2) throws Exception { + public boolean test(Integer t1, Integer t2) throws Throwable { out.add(t2); return t1.equals(t2); } @@ -213,7 +213,7 @@ public boolean test(Integer t1, Integer t2) throws Exception { } @Test - public void appendOnlyLinkedArrayListForEachWhileBiExact() throws Exception { + public void appendOnlyLinkedArrayListForEachWhileBiExact() throws Throwable { AppendOnlyLinkedArrayList list = new AppendOnlyLinkedArrayList(3); list.add(1); @@ -234,7 +234,7 @@ public boolean test(Integer t1, Integer t2) throws Exception { } @Test - public void appendOnlyLinkedArrayListForEachWhileBiAll() throws Exception { + public void appendOnlyLinkedArrayListForEachWhileBiAll() throws Throwable { AppendOnlyLinkedArrayList list = new AppendOnlyLinkedArrayList(2); list.add(1); diff --git a/src/test/java/io/reactivex/internal/util/TestingHelper.java b/src/test/java/io/reactivex/internal/util/TestingHelper.java index fe35f8cafa..7ddbe2f33f 100644 --- a/src/test/java/io/reactivex/internal/util/TestingHelper.java +++ b/src/test/java/io/reactivex/internal/util/TestingHelper.java @@ -15,12 +15,9 @@ */ package io.reactivex.internal.util; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Callable; +import java.util.*; -import io.reactivex.functions.BiConsumer; -import io.reactivex.functions.Consumer; +import io.reactivex.functions.*; public final class TestingHelper { @@ -38,11 +35,11 @@ public void accept(T t) { }; } - public static Callable> callableListCreator() { - return new Callable>() { + public static Supplier> supplierListCreator() { + return new Supplier>() { @Override - public List call() { + public List get() { return new ArrayList(); } }; diff --git a/src/test/java/io/reactivex/maybe/MaybeTest.java b/src/test/java/io/reactivex/maybe/MaybeTest.java index 45b31b0a8a..c79f9211cf 100644 --- a/src/test/java/io/reactivex/maybe/MaybeTest.java +++ b/src/test/java/io/reactivex/maybe/MaybeTest.java @@ -199,8 +199,8 @@ public void errorNull() { } @Test(expected = NullPointerException.class) - public void errorCallableNull() { - Maybe.error((Callable)null); + public void errorSupplierNull() { + Maybe.error((Supplier)null); } @Test @@ -212,14 +212,14 @@ public void error() { @Test public void errorCallable() { - Maybe.error(Functions.justCallable(new TestException())) + Maybe.error(Functions.justSupplier(new TestException())) .test() .assertFailure(TestException.class); } @Test public void errorCallableReturnsNull() { - Maybe.error(Functions.justCallable((Throwable)null)) + Maybe.error(Functions.justSupplier((Throwable)null)) .test() .assertFailure(NullPointerException.class); } @@ -293,9 +293,9 @@ public void deferNull() { @Test public void deferThrows() { - Maybe.defer(new Callable>() { + Maybe.defer(new Supplier>() { @Override - public Maybe call() throws Exception { + public Maybe get() throws Exception { throw new TestException(); } }) @@ -305,9 +305,9 @@ public Maybe call() throws Exception { @Test public void deferReturnsNull() { - Maybe.defer(new Callable>() { + Maybe.defer(new Supplier>() { @Override - public Maybe call() throws Exception { + public Maybe get() throws Exception { return null; } }) @@ -317,10 +317,10 @@ public Maybe call() throws Exception { @Test public void defer() { - Maybe source = Maybe.defer(new Callable>() { + Maybe source = Maybe.defer(new Supplier>() { int count; @Override - public Maybe call() throws Exception { + public Maybe get() throws Exception { return Maybe.just(count++); } }); @@ -1087,9 +1087,9 @@ public MaybeSource apply(Throwable v) throws Exception { } }, - new Callable>() { + new Supplier>() { @Override - public MaybeSource call() throws Exception { + public MaybeSource get() throws Exception { return Maybe.just(200); } }) @@ -1113,9 +1113,9 @@ public MaybeSource apply(Throwable v) throws Exception { } }, - new Callable>() { + new Supplier>() { @Override - public MaybeSource call() throws Exception { + public MaybeSource get() throws Exception { return Maybe.just(200); } }) @@ -1139,9 +1139,9 @@ public MaybeSource apply(Throwable v) throws Exception { } }, - new Callable>() { + new Supplier>() { @Override - public MaybeSource call() throws Exception { + public MaybeSource get() throws Exception { return Maybe.just(200); } }) @@ -2825,7 +2825,7 @@ public Observable apply(Integer v) throws Exception { public void using() { final AtomicInteger disposeCount = new AtomicInteger(); - Maybe.using(Functions.justCallable(1), new Function>() { + Maybe.using(Functions.justSupplier(1), new Function>() { @Override public MaybeSource apply(Integer v) throws Exception { return Maybe.just(v); @@ -2850,7 +2850,7 @@ public String apply(Integer v) throws Exception { public void usingNonEager() { final AtomicInteger disposeCount = new AtomicInteger(); - Maybe.using(Functions.justCallable(1), new Function>() { + Maybe.using(Functions.justSupplier(1), new Function>() { @Override public MaybeSource apply(Integer v) throws Exception { return Maybe.just(v); @@ -3188,9 +3188,9 @@ public Publisher apply(Flowable v) throws Exception final AtomicInteger calls = new AtomicInteger(); try { - Maybe.error(new Callable() { + Maybe.error(new Supplier() { @Override - public Throwable call() { + public Throwable get() { calls.incrementAndGet(); return new TestException(); } diff --git a/src/test/java/io/reactivex/observable/ObservableMergeTests.java b/src/test/java/io/reactivex/observable/ObservableMergeTests.java index c7ee01c591..23eb75ac5e 100644 --- a/src/test/java/io/reactivex/observable/ObservableMergeTests.java +++ b/src/test/java/io/reactivex/observable/ObservableMergeTests.java @@ -16,11 +16,11 @@ import static org.junit.Assert.*; import java.util.List; -import java.util.concurrent.Callable; import org.junit.Test; import io.reactivex.Observable; +import io.reactivex.functions.Supplier; import io.reactivex.observable.ObservableCovarianceTest.*; public class ObservableMergeTests { @@ -75,9 +75,9 @@ public void testMergeCovariance3() { @Test public void testMergeCovariance4() { - Observable o1 = Observable.defer(new Callable>() { + Observable o1 = Observable.defer(new Supplier>() { @Override - public Observable call() { + public Observable get() { return Observable.just( new HorrorMovie(), new Movie() diff --git a/src/test/java/io/reactivex/observable/ObservableNullTests.java b/src/test/java/io/reactivex/observable/ObservableNullTests.java index d4142b34af..7445c8e3cf 100644 --- a/src/test/java/io/reactivex/observable/ObservableNullTests.java +++ b/src/test/java/io/reactivex/observable/ObservableNullTests.java @@ -305,9 +305,9 @@ public void deferFunctionNull() { @Test(expected = NullPointerException.class) public void deferFunctionReturnsNull() { - Observable.defer(new Callable>() { + Observable.defer(new Supplier>() { @Override - public Observable call() { + public Observable get() { return null; } }).blockingLast(); @@ -315,14 +315,14 @@ public Observable call() { @Test(expected = NullPointerException.class) public void errorFunctionNull() { - Observable.error((Callable)null); + Observable.error((Supplier)null); } @Test(expected = NullPointerException.class) public void errorFunctionReturnsNull() { - Observable.error(new Callable() { + Observable.error(new Supplier() { @Override - public Throwable call() { + public Throwable get() { return null; } }).blockingSubscribe(); @@ -459,9 +459,9 @@ public void generateStateFunctionInitialStateNull() { @Test(expected = NullPointerException.class) public void generateStateConsumerNull() { - Observable.generate(new Callable() { + Observable.generate(new Supplier() { @Override - public Integer call() { + public Integer get() { return 1; } }, (BiConsumer>)null); @@ -475,9 +475,9 @@ public void accept(Integer s, Emitter o) { o.onComplete(); } }; - Observable.generate(new Callable() { + Observable.generate(new Supplier() { @Override - public Integer call() { + public Integer get() { return null; } }, generator).blockingSubscribe(); @@ -485,9 +485,9 @@ public Integer call() { @Test public void generateFunctionStateNullAllowed() { - Observable.generate(new Callable() { + Observable.generate(new Supplier() { @Override - public Object call() { + public Object get() { return null; } }, new BiFunction, Object>() { @@ -504,9 +504,9 @@ public void accept(Integer s, Emitter o) { o.onNext(1); } }; - Observable.generate(new Callable() { + Observable.generate(new Supplier() { @Override - public Integer call() { + public Integer get() { return 1; } }, generator, null); @@ -514,9 +514,9 @@ public Integer call() { @Test(expected = NullPointerException.class) public void generateFunctionDisposeNull() { - Observable.generate(new Callable() { + Observable.generate(new Supplier() { @Override - public Object call() { + public Object get() { return 1; } }, new BiFunction, Object>() { @@ -690,9 +690,9 @@ public void accept(Object d) { } @Test(expected = NullPointerException.class) public void usingObservableSupplierNull() { - Observable.using(new Callable() { + Observable.using(new Supplier() { @Override - public Object call() { + public Object get() { return 1; } }, null, new Consumer() { @@ -703,9 +703,9 @@ public void accept(Object d) { } @Test(expected = NullPointerException.class) public void usingObservableSupplierReturnsNull() { - Observable.using(new Callable() { + Observable.using(new Supplier() { @Override - public Object call() { + public Object get() { return 1; } }, new Function>() { @@ -721,9 +721,9 @@ public void accept(Object d) { } @Test(expected = NullPointerException.class) public void usingDisposeNull() { - Observable.using(new Callable() { + Observable.using(new Supplier() { @Override - public Object call() { + public Object get() { return 1; } }, new Function>() { @@ -864,14 +864,14 @@ public void anyPredicateNull() { @Test(expected = NullPointerException.class) public void bufferSupplierNull() { - just1.buffer(1, 1, (Callable>)null); + just1.buffer(1, 1, (Supplier>)null); } @Test(expected = NullPointerException.class) public void bufferSupplierReturnsNull() { - just1.buffer(1, 1, new Callable>() { + just1.buffer(1, 1, new Supplier>() { @Override - public Collection call() { + public Collection get() { return null; } }).blockingSubscribe(); @@ -894,9 +894,9 @@ public void bufferTimedSupplierNull() { @Test(expected = NullPointerException.class) public void bufferTimedSupplierReturnsNull() { - just1.buffer(1L, 1L, TimeUnit.SECONDS, Schedulers.single(), new Callable>() { + just1.buffer(1L, 1L, TimeUnit.SECONDS, Schedulers.single(), new Supplier>() { @Override - public Collection call() { + public Collection get() { return null; } }).blockingSubscribe(); @@ -934,14 +934,14 @@ public void bufferBoundaryNull() { @Test(expected = NullPointerException.class) public void bufferBoundarySupplierNull() { - just1.buffer(just1, (Callable>)null); + just1.buffer(just1, (Supplier>)null); } @Test(expected = NullPointerException.class) public void bufferBoundarySupplierReturnsNull() { - just1.buffer(just1, new Callable>() { + just1.buffer(just1, new Supplier>() { @Override - public Collection call() { + public Collection get() { return null; } }).blockingSubscribe(); @@ -949,14 +949,14 @@ public Collection call() { @Test(expected = NullPointerException.class) public void bufferBoundarySupplier2Null() { - just1.buffer((Callable>)null); + just1.buffer((Supplier>)null); } @Test(expected = NullPointerException.class) public void bufferBoundarySupplier2ReturnsNull() { - just1.buffer(new Callable>() { + just1.buffer(new Supplier>() { @Override - public Observable call() { + public Observable get() { return null; } }).blockingSubscribe(); @@ -964,9 +964,9 @@ public Observable call() { @Test(expected = NullPointerException.class) public void bufferBoundarySupplier2SupplierNull() { - just1.buffer(new Callable>() { + just1.buffer(new Supplier>() { @Override - public Observable call() { + public Observable get() { return just1; } }, null); @@ -974,14 +974,14 @@ public Observable call() { @Test(expected = NullPointerException.class) public void bufferBoundarySupplier2SupplierReturnsNull() { - just1.buffer(new Callable>() { + just1.buffer(new Supplier>() { @Override - public Observable call() { + public Observable get() { return just1; } - }, new Callable>() { + }, new Supplier>() { @Override - public Collection call() { + public Collection get() { return null; } }).blockingSubscribe(); @@ -994,7 +994,7 @@ public void castNull() { @Test(expected = NullPointerException.class) public void collectInitialSupplierNull() { - just1.collect((Callable)null, new BiConsumer() { + just1.collect((Supplier)null, new BiConsumer() { @Override public void accept(Integer a, Integer b) { } }); @@ -1002,9 +1002,9 @@ public void accept(Integer a, Integer b) { } @Test(expected = NullPointerException.class) public void collectInitialSupplierReturnsNull() { - just1.collect(new Callable() { + just1.collect(new Supplier() { @Override - public Object call() { + public Object get() { return null; } }, new BiConsumer() { @@ -1015,9 +1015,9 @@ public void accept(Object a, Integer b) { } @Test(expected = NullPointerException.class) public void collectInitialCollectorNull() { - just1.collect(new Callable() { + just1.collect(new Supplier() { @Override - public Object call() { + public Object get() { return 1; } }, null); @@ -1229,9 +1229,9 @@ public void distinctSupplierReturnsNull() { public Object apply(Integer v) { return v; } - }, new Callable>() { + }, new Supplier>() { @Override - public Collection call() { + public Collection get() { return null; } }).blockingSubscribe(); @@ -1362,9 +1362,9 @@ public void flatMapNotificationOnNextNull() { public Observable apply(Throwable e) { return just1; } - }, new Callable>() { + }, new Supplier>() { @Override - public Observable call() { + public Observable get() { return just1; } }); @@ -1382,9 +1382,9 @@ public Observable apply(Integer v) { public Observable apply(Throwable e) { return just1; } - }, new Callable>() { + }, new Supplier>() { @Override - public Observable call() { + public Observable get() { return just1; } }).blockingSubscribe(); @@ -1397,9 +1397,9 @@ public void flatMapNotificationOnErrorNull() { public Observable apply(Integer v) { return just1; } - }, null, new Callable>() { + }, null, new Supplier>() { @Override - public Observable call() { + public Observable get() { return just1; } }); @@ -1418,9 +1418,9 @@ public Observable apply(Object v) { public Observable apply(Throwable e) { return null; } - }, new Callable>() { + }, new Supplier>() { @Override - public Observable call() { + public Observable get() { return just1; } }).blockingSubscribe(); @@ -1453,9 +1453,9 @@ public Observable apply(Integer v) { public Observable apply(Throwable e) { return just1; } - }, new Callable>() { + }, new Supplier>() { @Override - public Observable call() { + public Observable get() { return null; } }).blockingSubscribe(); @@ -1810,9 +1810,9 @@ public Object apply(Object a, Integer b) { @Test(expected = NullPointerException.class) public void reduceWithSeedReturnsNull() { - just1.reduceWith(new Callable() { + just1.reduceWith(new Supplier() { @Override - public Object call() { + public Object get() { return null; } }, new BiFunction() { @@ -2065,9 +2065,9 @@ public Object apply(Object a, Integer b) { @Test(expected = NullPointerException.class) public void scanSeedSupplierReturnsNull() { - just1.scanWith(new Callable() { + just1.scanWith(new Supplier() { @Override - public Object call() { + public Object get() { return null; } }, new BiFunction() { @@ -2080,9 +2080,9 @@ public Object apply(Object a, Integer b) { @Test(expected = NullPointerException.class) public void scanSeedSupplierFunctionNull() { - just1.scanWith(new Callable() { + just1.scanWith(new Supplier() { @Override - public Object call() { + public Object get() { return 1; } }, null); @@ -2090,9 +2090,9 @@ public Object call() { @Test(expected = NullPointerException.class) public void scanSeedSupplierFunctionReturnsNull() { - just1.scanWith(new Callable() { + just1.scanWith(new Supplier() { @Override - public Object call() { + public Object get() { return 1; } }, new BiFunction() { @@ -2420,9 +2420,9 @@ public void toListNull() { @Test(expected = NullPointerException.class) public void toListSupplierReturnsNull() { - just1.toList(new Callable>() { + just1.toList(new Supplier>() { @Override - public Collection call() { + public Collection get() { return null; } }).blockingGet(); @@ -2490,9 +2490,9 @@ public Object apply(Integer v) { public Object apply(Integer v) { return v; } - }, new Callable>() { + }, new Supplier>() { @Override - public Map call() { + public Map get() { return null; } }).blockingGet(); @@ -2555,9 +2555,9 @@ public Object apply(Integer v) { public Object apply(Integer v) { return v; } - }, new Callable>>() { + }, new Supplier>>() { @Override - public Map> call() { + public Map> get() { return null; } }).blockingGet(); @@ -2575,9 +2575,9 @@ public Integer apply(Integer v) { public Integer apply(Integer v) { return v; } - }, new Callable>>() { + }, new Supplier>>() { @Override - public Map> call() { + public Map> get() { return new HashMap>(); } }, null); @@ -2595,9 +2595,9 @@ public Integer apply(Integer v) { public Integer apply(Integer v) { return v; } - }, new Callable>>() { + }, new Supplier>>() { @Override - public Map> call() { + public Map> get() { return new HashMap>(); } }, new Function>() { @@ -2670,14 +2670,14 @@ public Observable apply(Integer v) { @Test(expected = NullPointerException.class) public void windowBoundarySupplierNull() { - just1.window((Callable>)null); + just1.window((Supplier>)null); } @Test(expected = NullPointerException.class) public void windowBoundarySupplierReturnsNull() { - just1.window(new Callable>() { + just1.window(new Supplier>() { @Override - public Observable call() { + public Observable get() { return null; } }).blockingSubscribe(); diff --git a/src/test/java/io/reactivex/observable/ObservableTest.java b/src/test/java/io/reactivex/observable/ObservableTest.java index ab915ffa53..019dcf0ab3 100644 --- a/src/test/java/io/reactivex/observable/ObservableTest.java +++ b/src/test/java/io/reactivex/observable/ObservableTest.java @@ -134,9 +134,9 @@ public void testCountZeroItemsObservable() { @Test public void testCountErrorObservable() { - Observable o = Observable.error(new Callable() { + Observable o = Observable.error(new Supplier() { @Override - public Throwable call() { + public Throwable get() { return new RuntimeException(); } }); @@ -171,9 +171,9 @@ public void testCountZeroItems() { @Test public void testCountError() { - Observable o = Observable.error(new Callable() { + Observable o = Observable.error(new Supplier() { @Override - public Throwable call() { + public Throwable get() { return new RuntimeException(); } }); @@ -476,9 +476,9 @@ public void testCustomObservableWithErrorInObservableSynchronous() { final AtomicInteger count = new AtomicInteger(); final AtomicReference error = new AtomicReference(); // FIXME custom built??? - Observable.just("1", "2").concatWith(Observable.error(new Callable() { + Observable.just("1", "2").concatWith(Observable.error(new Supplier() { @Override - public Throwable call() { + public Throwable get() { return new NumberFormatException(); } })) diff --git a/src/test/java/io/reactivex/parallel/ParallelCollectTest.java b/src/test/java/io/reactivex/parallel/ParallelCollectTest.java index 4072a5c575..088a0714f0 100644 --- a/src/test/java/io/reactivex/parallel/ParallelCollectTest.java +++ b/src/test/java/io/reactivex/parallel/ParallelCollectTest.java @@ -16,7 +16,6 @@ import static org.junit.Assert.*; import java.util.*; -import java.util.concurrent.Callable; import org.junit.Test; @@ -32,9 +31,9 @@ public class ParallelCollectTest { @Test public void subscriberCount() { ParallelFlowableTest.checkSubscriberCount(Flowable.range(1, 5).parallel() - .collect(new Callable>() { + .collect(new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { return new ArrayList(); } }, new BiConsumer, Integer>() { @@ -50,9 +49,9 @@ public void accept(List a, Integer b) throws Exception { public void initialCrash() { Flowable.range(1, 5) .parallel() - .collect(new Callable>() { + .collect(new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { throw new TestException(); } }, new BiConsumer, Integer>() { @@ -71,9 +70,9 @@ public void accept(List a, Integer b) throws Exception { public void reducerCrash() { Flowable.range(1, 5) .parallel() - .collect(new Callable>() { + .collect(new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { return new ArrayList(); } }, new BiConsumer, Integer>() { @@ -96,9 +95,9 @@ public void cancel() { TestSubscriber> ts = pp .parallel() - .collect(new Callable>() { + .collect(new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { return new ArrayList(); } }, new BiConsumer, Integer>() { @@ -122,9 +121,9 @@ public void accept(List a, Integer b) throws Exception { public void error() { Flowable.error(new TestException()) .parallel() - .collect(new Callable>() { + .collect(new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { return new ArrayList(); } }, new BiConsumer, Integer>() { @@ -144,9 +143,9 @@ public void doubleError() { List errors = TestHelper.trackPluginErrors(); try { new ParallelInvalid() - .collect(new Callable>() { + .collect(new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { return new ArrayList(); } }, new BiConsumer, Object>() { diff --git a/src/test/java/io/reactivex/parallel/ParallelFlowableTest.java b/src/test/java/io/reactivex/parallel/ParallelFlowableTest.java index ab98b5a9f4..375013e022 100644 --- a/src/test/java/io/reactivex/parallel/ParallelFlowableTest.java +++ b/src/test/java/io/reactivex/parallel/ParallelFlowableTest.java @@ -274,9 +274,9 @@ public void sorted() { @Test public void collect() { - Callable> as = new Callable>() { + Supplier> as = new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { return new ArrayList(); } }; @@ -367,9 +367,9 @@ public void collectAsyncFused() { Scheduler s = Schedulers.from(exec); try { - Callable> as = new Callable>() { + Supplier> as = new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { return new ArrayList(); } }; @@ -414,9 +414,9 @@ public void collectAsync() { Scheduler s = Schedulers.from(exec); try { - Callable> as = new Callable>() { + Supplier> as = new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { return new ArrayList(); } }; @@ -461,9 +461,9 @@ public void collectAsync2() { Scheduler s = Schedulers.from(exec); try { - Callable> as = new Callable>() { + Supplier> as = new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { return new ArrayList(); } }; @@ -509,9 +509,9 @@ public void collectAsync3() { Scheduler s = Schedulers.from(exec); try { - Callable> as = new Callable>() { + Supplier> as = new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { return new ArrayList(); } }; @@ -557,9 +557,9 @@ public void collectAsync3Fused() { Scheduler s = Schedulers.from(exec); try { - Callable> as = new Callable>() { + Supplier> as = new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { return new ArrayList(); } }; @@ -605,9 +605,9 @@ public void collectAsync3Take() { Scheduler s = Schedulers.from(exec); try { - Callable> as = new Callable>() { + Supplier> as = new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { return new ArrayList(); } }; @@ -654,9 +654,9 @@ public void collectAsync4Take() { Scheduler s = Schedulers.from(exec); try { - Callable> as = new Callable>() { + Supplier> as = new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { return new ArrayList(); } }; diff --git a/src/test/java/io/reactivex/parallel/ParallelFromPublisherTest.java b/src/test/java/io/reactivex/parallel/ParallelFromPublisherTest.java index 48da2c566f..202e4dd0fc 100644 --- a/src/test/java/io/reactivex/parallel/ParallelFromPublisherTest.java +++ b/src/test/java/io/reactivex/parallel/ParallelFromPublisherTest.java @@ -101,7 +101,7 @@ public int requestFusion(int mode) { } @Override - public T poll() throws Exception { + public T poll() throws Throwable { return qs.poll(); } } diff --git a/src/test/java/io/reactivex/parallel/ParallelReduceTest.java b/src/test/java/io/reactivex/parallel/ParallelReduceTest.java index bd679e7e92..4a1d110bc0 100644 --- a/src/test/java/io/reactivex/parallel/ParallelReduceTest.java +++ b/src/test/java/io/reactivex/parallel/ParallelReduceTest.java @@ -14,8 +14,8 @@ package io.reactivex.parallel; import static org.junit.Assert.*; + import java.util.*; -import java.util.concurrent.Callable; import org.junit.Test; @@ -31,9 +31,9 @@ public class ParallelReduceTest { @Test public void subscriberCount() { ParallelFlowableTest.checkSubscriberCount(Flowable.range(1, 5).parallel() - .reduce(new Callable>() { + .reduce(new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { return new ArrayList(); } }, new BiFunction, Integer, List>() { @@ -50,9 +50,9 @@ public List apply(List a, Integer b) throws Exception { public void initialCrash() { Flowable.range(1, 5) .parallel() - .reduce(new Callable>() { + .reduce(new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { throw new TestException(); } }, new BiFunction, Integer, List>() { @@ -72,9 +72,9 @@ public List apply(List a, Integer b) throws Exception { public void reducerCrash() { Flowable.range(1, 5) .parallel() - .reduce(new Callable>() { + .reduce(new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { return new ArrayList(); } }, new BiFunction, Integer, List>() { @@ -98,9 +98,9 @@ public void cancel() { TestSubscriber> ts = pp .parallel() - .reduce(new Callable>() { + .reduce(new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { return new ArrayList(); } }, new BiFunction, Integer, List>() { @@ -125,9 +125,9 @@ public List apply(List a, Integer b) throws Exception { public void error() { Flowable.error(new TestException()) .parallel() - .reduce(new Callable>() { + .reduce(new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { return new ArrayList(); } }, new BiFunction, Integer, List>() { @@ -148,9 +148,9 @@ public void doubleError() { List errors = TestHelper.trackPluginErrors(); try { new ParallelInvalid() - .reduce(new Callable>() { + .reduce(new Supplier>() { @Override - public List call() throws Exception { + public List get() throws Exception { return new ArrayList(); } }, new BiFunction, Object, List>() { diff --git a/src/test/java/io/reactivex/plugins/RxJavaPluginsTest.java b/src/test/java/io/reactivex/plugins/RxJavaPluginsTest.java index efd4642d7e..eb8e613f1b 100644 --- a/src/test/java/io/reactivex/plugins/RxJavaPluginsTest.java +++ b/src/test/java/io/reactivex/plugins/RxJavaPluginsTest.java @@ -158,9 +158,9 @@ public void assemblyTrackingSingle() { } // static Completable createCompletable() { -// return Completable.error(new Callable() { +// return Completable.error(new Supplier() { // @Override -// public Throwable call() { +// public Throwable get() { // return new TestException(); // } // }); @@ -212,9 +212,9 @@ public void lockdown() throws Exception { try { assertTrue(RxJavaPlugins.isLockdown()); Consumer a1 = Functions.emptyConsumer(); - Callable f0 = new Callable() { + Supplier f0 = new Supplier() { @Override - public Object call() { + public Object get() { return null; } }; @@ -252,7 +252,7 @@ public boolean getAsBoolean() throws Exception { if (paramType.isAssignableFrom(Boolean.TYPE)) { m.invoke(null, true); } else - if (paramType.isAssignableFrom(Callable.class)) { + if (paramType.isAssignableFrom(Supplier.class)) { m.invoke(null, f0); } else if (paramType.isAssignableFrom(Function.class)) { @@ -364,9 +364,9 @@ public void overrideNewThreadScheduler() { assertNotSame(ImmediateThinScheduler.INSTANCE, Schedulers.newThread()); } - Function, Scheduler> initReplaceWithImmediate = new Function, Scheduler>() { + Function, Scheduler> initReplaceWithImmediate = new Function, Scheduler>() { @Override - public Scheduler apply(Callable t) { + public Scheduler apply(Supplier t) { return ImmediateThinScheduler.INSTANCE; } }; @@ -374,9 +374,9 @@ public Scheduler apply(Callable t) { @Test public void overrideInitSingleScheduler() { final Scheduler s = Schedulers.single(); // make sure the Schedulers is initialized - Callable c = new Callable() { + Supplier c = new Supplier() { @Override - public Scheduler call() throws Exception { + public Scheduler get() throws Exception { return s; } }; @@ -394,9 +394,9 @@ public Scheduler call() throws Exception { @Test public void overrideInitComputationScheduler() { final Scheduler s = Schedulers.computation(); // make sure the Schedulers is initialized - Callable c = new Callable() { + Supplier c = new Supplier() { @Override - public Scheduler call() throws Exception { + public Scheduler get() throws Exception { return s; } }; @@ -414,9 +414,9 @@ public Scheduler call() throws Exception { @Test public void overrideInitIoScheduler() { final Scheduler s = Schedulers.io(); // make sure the Schedulers is initialized; - Callable c = new Callable() { + Supplier c = new Supplier() { @Override - public Scheduler call() throws Exception { + public Scheduler get() throws Exception { return s; } }; @@ -434,9 +434,9 @@ public Scheduler call() throws Exception { @Test public void overrideInitNewThreadScheduler() { final Scheduler s = Schedulers.newThread(); // make sure the Schedulers is initialized; - Callable c = new Callable() { + Supplier c = new Supplier() { @Override - public Scheduler call() throws Exception { + public Scheduler get() throws Exception { return s; } }; @@ -451,100 +451,100 @@ public Scheduler call() throws Exception { assertSame(s, RxJavaPlugins.initNewThreadScheduler(c)); } - Callable nullResultCallable = new Callable() { + Supplier nullResultSupplier = new Supplier() { @Override - public Scheduler call() throws Exception { + public Scheduler get() throws Exception { return null; } }; @Test public void overrideInitSingleSchedulerCrashes() { - // fail when Callable is null + // fail when Supplier is null try { RxJavaPlugins.initSingleScheduler(null); fail("Should have thrown NullPointerException"); } catch (NullPointerException npe) { - assertEquals("Scheduler Callable can't be null", npe.getMessage()); + assertEquals("Scheduler Supplier can't be null", npe.getMessage()); } - // fail when Callable result is null + // fail when Supplier result is null try { - RxJavaPlugins.initSingleScheduler(nullResultCallable); + RxJavaPlugins.initSingleScheduler(nullResultSupplier); fail("Should have thrown NullPointerException"); } catch (NullPointerException npe) { - assertEquals("Scheduler Callable result can't be null", npe.getMessage()); + assertEquals("Scheduler Supplier result can't be null", npe.getMessage()); } } @Test public void overrideInitComputationSchedulerCrashes() { - // fail when Callable is null + // fail when Supplier is null try { RxJavaPlugins.initComputationScheduler(null); fail("Should have thrown NullPointerException"); } catch (NullPointerException npe) { - assertEquals("Scheduler Callable can't be null", npe.getMessage()); + assertEquals("Scheduler Supplier can't be null", npe.getMessage()); } - // fail when Callable result is null + // fail when Supplier result is null try { - RxJavaPlugins.initComputationScheduler(nullResultCallable); + RxJavaPlugins.initComputationScheduler(nullResultSupplier); fail("Should have thrown NullPointerException"); } catch (NullPointerException npe) { - assertEquals("Scheduler Callable result can't be null", npe.getMessage()); + assertEquals("Scheduler Supplier result can't be null", npe.getMessage()); } } @Test public void overrideInitIoSchedulerCrashes() { - // fail when Callable is null + // fail when Supplier is null try { RxJavaPlugins.initIoScheduler(null); fail("Should have thrown NullPointerException"); } catch (NullPointerException npe) { - assertEquals("Scheduler Callable can't be null", npe.getMessage()); + assertEquals("Scheduler Supplier can't be null", npe.getMessage()); } - // fail when Callable result is null + // fail when Supplier result is null try { - RxJavaPlugins.initIoScheduler(nullResultCallable); + RxJavaPlugins.initIoScheduler(nullResultSupplier); fail("Should have thrown NullPointerException"); } catch (NullPointerException npe) { - assertEquals("Scheduler Callable result can't be null", npe.getMessage()); + assertEquals("Scheduler Supplier result can't be null", npe.getMessage()); } } @Test public void overrideInitNewThreadSchedulerCrashes() { - // fail when Callable is null + // fail when Supplier is null try { RxJavaPlugins.initNewThreadScheduler(null); fail("Should have thrown NullPointerException"); } catch (NullPointerException npe) { // expected - assertEquals("Scheduler Callable can't be null", npe.getMessage()); + assertEquals("Scheduler Supplier can't be null", npe.getMessage()); } - // fail when Callable result is null + // fail when Supplier result is null try { - RxJavaPlugins.initNewThreadScheduler(nullResultCallable); + RxJavaPlugins.initNewThreadScheduler(nullResultSupplier); fail("Should have thrown NullPointerException"); } catch (NullPointerException npe) { - assertEquals("Scheduler Callable result can't be null", npe.getMessage()); + assertEquals("Scheduler Supplier result can't be null", npe.getMessage()); } } - Callable unsafeDefault = new Callable() { + Supplier unsafeDefault = new Supplier() { @Override - public Scheduler call() throws Exception { + public Scheduler get() throws Exception { throw new AssertionError("Default Scheduler instance should not have been evaluated"); } }; @Test public void testDefaultSingleSchedulerIsInitializedLazily() { - // unsafe default Scheduler Callable should not be evaluated + // unsafe default Scheduler Supplier should not be evaluated try { RxJavaPlugins.setInitSingleSchedulerHandler(initReplaceWithImmediate); RxJavaPlugins.initSingleScheduler(unsafeDefault); @@ -558,7 +558,7 @@ public void testDefaultSingleSchedulerIsInitializedLazily() { @Test public void testDefaultIoSchedulerIsInitializedLazily() { - // unsafe default Scheduler Callable should not be evaluated + // unsafe default Scheduler Supplier should not be evaluated try { RxJavaPlugins.setInitIoSchedulerHandler(initReplaceWithImmediate); RxJavaPlugins.initIoScheduler(unsafeDefault); @@ -572,7 +572,7 @@ public void testDefaultIoSchedulerIsInitializedLazily() { @Test public void testDefaultComputationSchedulerIsInitializedLazily() { - // unsafe default Scheduler Callable should not be evaluated + // unsafe default Scheduler Supplier should not be evaluated try { RxJavaPlugins.setInitComputationSchedulerHandler(initReplaceWithImmediate); RxJavaPlugins.initComputationScheduler(unsafeDefault); @@ -586,7 +586,7 @@ public void testDefaultComputationSchedulerIsInitializedLazily() { @Test public void testDefaultNewThreadSchedulerIsInitializedLazily() { - // unsafe default Scheduler Callable should not be evaluated + // unsafe default Scheduler Supplier should not be evaluated try { RxJavaPlugins.setInitNewThreadSchedulerHandler(initReplaceWithImmediate); RxJavaPlugins.initNewThreadScheduler(unsafeDefault); @@ -1194,10 +1194,10 @@ public Scheduler apply(Scheduler scheduler) throws Exception { return scheduler; } }; - Function, ? extends Scheduler> callable2scheduler = new Function, Scheduler>() { + Function, ? extends Scheduler> callable2scheduler = new Function, Scheduler>() { @Override - public Scheduler apply(Callable schedulerCallable) throws Exception { - return schedulerCallable.call(); + public Scheduler apply(Supplier schedulerSupplier) throws Throwable { + return schedulerSupplier.get(); } }; Function connectableFlowable2ConnectableFlowable = new Function() { @@ -1488,9 +1488,9 @@ public void onComplete() { // assertSame(cop, RxJavaPlugins.onCompletableLift(cop)); final Scheduler s = ImmediateThinScheduler.INSTANCE; - Callable c = new Callable() { + Supplier c = new Supplier() { @Override - public Scheduler call() throws Exception { + public Scheduler get() throws Exception { return s; } }; diff --git a/src/test/java/io/reactivex/schedulers/TestSchedulerTest.java b/src/test/java/io/reactivex/schedulers/TestSchedulerTest.java index 4139365384..2859918eec 100644 --- a/src/test/java/io/reactivex/schedulers/TestSchedulerTest.java +++ b/src/test/java/io/reactivex/schedulers/TestSchedulerTest.java @@ -36,7 +36,7 @@ public class TestSchedulerTest { @SuppressWarnings("unchecked") // mocking is unchecked, unfortunately @Test - public final void testPeriodicScheduling() throws Exception { + public final void testPeriodicScheduling() throws Throwable { final Function calledOp = mock(Function.class); final TestScheduler scheduler = new TestScheduler(); @@ -86,7 +86,7 @@ public void run() { @SuppressWarnings("unchecked") // mocking is unchecked, unfortunately @Test - public final void testPeriodicSchedulingUnsubscription() throws Exception { + public final void testPeriodicSchedulingUnsubscription() throws Throwable { final Function calledOp = mock(Function.class); final TestScheduler scheduler = new TestScheduler(); diff --git a/src/test/java/io/reactivex/single/SingleNullTests.java b/src/test/java/io/reactivex/single/SingleNullTests.java index ff7ddf19d0..0e9dbe871c 100644 --- a/src/test/java/io/reactivex/single/SingleNullTests.java +++ b/src/test/java/io/reactivex/single/SingleNullTests.java @@ -142,7 +142,7 @@ public void deferReturnsNull() { @Test(expected = NullPointerException.class) public void errorSupplierNull() { - Single.error((Callable)null); + Single.error((Supplier)null); } @Test(expected = NullPointerException.class) @@ -321,9 +321,9 @@ public Single apply(Object d) { @Test(expected = NullPointerException.class) public void usingSingleSupplierNull() { - Single.using(new Callable() { + Single.using(new Supplier() { @Override - public Object call() { + public Object get() { return 1; } }, null, Functions.emptyConsumer()); @@ -331,9 +331,9 @@ public Object call() { @Test(expected = NullPointerException.class) public void usingSingleSupplierReturnsNull() { - Single.using(new Callable() { + Single.using(new Supplier() { @Override - public Object call() { + public Object get() { return 1; } }, new Function>() { @@ -346,9 +346,9 @@ public Single apply(Object d) { @Test(expected = NullPointerException.class) public void usingDisposeNull() { - Single.using(new Callable() { + Single.using(new Supplier() { @Override - public Object call() { + public Object get() { return 1; } }, new Function>() { diff --git a/src/test/java/io/reactivex/tck/DeferTckTest.java b/src/test/java/io/reactivex/tck/DeferTckTest.java index 87301df0e3..1f3ba83fa4 100644 --- a/src/test/java/io/reactivex/tck/DeferTckTest.java +++ b/src/test/java/io/reactivex/tck/DeferTckTest.java @@ -13,12 +13,11 @@ package io.reactivex.tck; -import java.util.concurrent.Callable; - import org.reactivestreams.Publisher; import org.testng.annotations.Test; import io.reactivex.Flowable; +import io.reactivex.functions.Supplier; @Test public class DeferTckTest extends BaseTck { @@ -26,9 +25,9 @@ public class DeferTckTest extends BaseTck { @Override public Publisher createPublisher(final long elements) { return - Flowable.defer(new Callable>() { + Flowable.defer(new Supplier>() { @Override - public Publisher call() throws Exception { + public Publisher get() throws Exception { return Flowable.fromIterable(iterate(elements)); } } diff --git a/src/test/java/io/reactivex/tck/GenerateTckTest.java b/src/test/java/io/reactivex/tck/GenerateTckTest.java index 3bff69e248..55ab711f48 100644 --- a/src/test/java/io/reactivex/tck/GenerateTckTest.java +++ b/src/test/java/io/reactivex/tck/GenerateTckTest.java @@ -26,7 +26,7 @@ public class GenerateTckTest extends BaseTck { @Override public Publisher createPublisher(final long elements) { return - Flowable.generate(Functions.justCallable(0L), + Flowable.generate(Functions.justSupplier(0L), new BiFunction, Long>() { @Override public Long apply(Long s, Emitter e) throws Exception { diff --git a/src/test/java/io/reactivex/tck/ReduceWithTckTest.java b/src/test/java/io/reactivex/tck/ReduceWithTckTest.java index c3899641df..f05c94428b 100644 --- a/src/test/java/io/reactivex/tck/ReduceWithTckTest.java +++ b/src/test/java/io/reactivex/tck/ReduceWithTckTest.java @@ -26,7 +26,7 @@ public class ReduceWithTckTest extends BaseTck { @Override public Publisher createPublisher(final long elements) { return - Flowable.range(1, 1000).reduceWith(Functions.justCallable(0), + Flowable.range(1, 1000).reduceWith(Functions.justSupplier(0), new BiFunction() { @Override public Integer apply(Integer a, Integer b) throws Exception { diff --git a/src/test/java/io/reactivex/tck/UsingTckTest.java b/src/test/java/io/reactivex/tck/UsingTckTest.java index ad40263c97..094ffd06bb 100644 --- a/src/test/java/io/reactivex/tck/UsingTckTest.java +++ b/src/test/java/io/reactivex/tck/UsingTckTest.java @@ -25,7 +25,7 @@ public class UsingTckTest extends BaseTck { @Override public Publisher createPublisher(long elements) { return - Flowable.using(Functions.justCallable(1), + Flowable.using(Functions.justSupplier(1), Functions.justFunction(Flowable.fromIterable(iterate(elements))), Functions.emptyConsumer() ) diff --git a/src/test/java/io/reactivex/validators/ParamValidationCheckerTest.java b/src/test/java/io/reactivex/validators/ParamValidationCheckerTest.java index 2d7a9649b8..3cc1605346 100644 --- a/src/test/java/io/reactivex/validators/ParamValidationCheckerTest.java +++ b/src/test/java/io/reactivex/validators/ParamValidationCheckerTest.java @@ -110,15 +110,15 @@ public void checkParallelFlowable() { addOverride(new ParamOverride(Flowable.class, 0, ParamMode.ANY, "buffer", Long.TYPE, TimeUnit.class, Integer.TYPE)); addOverride(new ParamOverride(Flowable.class, 0, ParamMode.ANY, "buffer", Long.TYPE, TimeUnit.class, Scheduler.class)); addOverride(new ParamOverride(Flowable.class, 0, ParamMode.ANY, "buffer", Long.TYPE, TimeUnit.class, Scheduler.class, Integer.TYPE)); - addOverride(new ParamOverride(Flowable.class, 0, ParamMode.ANY, "buffer", Long.TYPE, TimeUnit.class, Scheduler.class, Integer.TYPE, Callable.class, Boolean.TYPE)); + addOverride(new ParamOverride(Flowable.class, 0, ParamMode.ANY, "buffer", Long.TYPE, TimeUnit.class, Scheduler.class, Integer.TYPE, Supplier.class, Boolean.TYPE)); // negative time/skip is considered zero time/skip addOverride(new ParamOverride(Flowable.class, 0, ParamMode.ANY, "buffer", Long.TYPE, Long.TYPE, TimeUnit.class)); addOverride(new ParamOverride(Flowable.class, 0, ParamMode.ANY, "buffer", Long.TYPE, Long.TYPE, TimeUnit.class, Scheduler.class)); - addOverride(new ParamOverride(Flowable.class, 0, ParamMode.ANY, "buffer", Long.TYPE, Long.TYPE, TimeUnit.class, Scheduler.class, Callable.class)); + addOverride(new ParamOverride(Flowable.class, 0, ParamMode.ANY, "buffer", Long.TYPE, Long.TYPE, TimeUnit.class, Scheduler.class, Supplier.class)); addOverride(new ParamOverride(Flowable.class, 1, ParamMode.ANY, "buffer", Long.TYPE, Long.TYPE, TimeUnit.class)); addOverride(new ParamOverride(Flowable.class, 1, ParamMode.ANY, "buffer", Long.TYPE, Long.TYPE, TimeUnit.class, Scheduler.class)); - addOverride(new ParamOverride(Flowable.class, 1, ParamMode.ANY, "buffer", Long.TYPE, Long.TYPE, TimeUnit.class, Scheduler.class, Callable.class)); + addOverride(new ParamOverride(Flowable.class, 1, ParamMode.ANY, "buffer", Long.TYPE, Long.TYPE, TimeUnit.class, Scheduler.class, Supplier.class)); // negative timeout is allowed addOverride(new ParamOverride(Flowable.class, 1, ParamMode.ANY, "fromFuture", Future.class, Long.TYPE, TimeUnit.class)); @@ -366,15 +366,15 @@ public void checkParallelFlowable() { addOverride(new ParamOverride(Observable.class, 0, ParamMode.ANY, "buffer", Long.TYPE, TimeUnit.class, Integer.TYPE)); addOverride(new ParamOverride(Observable.class, 0, ParamMode.ANY, "buffer", Long.TYPE, TimeUnit.class, Scheduler.class)); addOverride(new ParamOverride(Observable.class, 0, ParamMode.ANY, "buffer", Long.TYPE, TimeUnit.class, Scheduler.class, Integer.TYPE)); - addOverride(new ParamOverride(Observable.class, 0, ParamMode.ANY, "buffer", Long.TYPE, TimeUnit.class, Scheduler.class, Integer.TYPE, Callable.class, Boolean.TYPE)); + addOverride(new ParamOverride(Observable.class, 0, ParamMode.ANY, "buffer", Long.TYPE, TimeUnit.class, Scheduler.class, Integer.TYPE, Supplier.class, Boolean.TYPE)); // negative time/skip is considered zero time/skip addOverride(new ParamOverride(Observable.class, 0, ParamMode.ANY, "buffer", Long.TYPE, Long.TYPE, TimeUnit.class)); addOverride(new ParamOverride(Observable.class, 0, ParamMode.ANY, "buffer", Long.TYPE, Long.TYPE, TimeUnit.class, Scheduler.class)); - addOverride(new ParamOverride(Observable.class, 0, ParamMode.ANY, "buffer", Long.TYPE, Long.TYPE, TimeUnit.class, Scheduler.class, Callable.class)); + addOverride(new ParamOverride(Observable.class, 0, ParamMode.ANY, "buffer", Long.TYPE, Long.TYPE, TimeUnit.class, Scheduler.class, Supplier.class)); addOverride(new ParamOverride(Observable.class, 1, ParamMode.ANY, "buffer", Long.TYPE, Long.TYPE, TimeUnit.class)); addOverride(new ParamOverride(Observable.class, 1, ParamMode.ANY, "buffer", Long.TYPE, Long.TYPE, TimeUnit.class, Scheduler.class)); - addOverride(new ParamOverride(Observable.class, 1, ParamMode.ANY, "buffer", Long.TYPE, Long.TYPE, TimeUnit.class, Scheduler.class, Callable.class)); + addOverride(new ParamOverride(Observable.class, 1, ParamMode.ANY, "buffer", Long.TYPE, Long.TYPE, TimeUnit.class, Scheduler.class, Supplier.class)); // negative timeout is allowed addOverride(new ParamOverride(Observable.class, 1, ParamMode.ANY, "fromFuture", Future.class, Long.TYPE, TimeUnit.class)); @@ -551,6 +551,7 @@ public void checkParallelFlowable() { defaultValues.put(LongConsumer.class, Functions.EMPTY_LONG_CONSUMER); defaultValues.put(Function.class, Functions.justFunction(1)); defaultValues.put(Callable.class, Functions.justCallable(1)); + defaultValues.put(Supplier.class, Functions.justSupplier(1)); defaultValues.put(Iterable.class, Collections.emptyList()); defaultValues.put(Object.class, 1); defaultValues.put(Class.class, Integer.class); From c7794750ec81a1c467ed7b4a944089849d620c94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Karnok?= Date: Mon, 17 Jun 2019 20:10:41 +0200 Subject: [PATCH 2/3] Fix typo and wrong link in Supplier, some style cleanup --- src/main/java/io/reactivex/functions/Supplier.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/io/reactivex/functions/Supplier.java b/src/main/java/io/reactivex/functions/Supplier.java index 8ce42202f3..0e76500ede 100644 --- a/src/main/java/io/reactivex/functions/Supplier.java +++ b/src/main/java/io/reactivex/functions/Supplier.java @@ -17,8 +17,8 @@ * A functional interface (callback) that provides a single value or * throws an exception. *

- * Thins interface was added to allow throwing any subclass of {@link Throwable}s, - * which is not directly possible with the Java standard {@link java.util.Callable} interface. + * This interface was added to allow throwing any subclass of {@link Throwable}s, + * which is not directly possible with the Java standard {@link java.util.concurrent.Callable} interface. * @param the value type returned * @since 3.0.0 */ From 89087d76afdb6ee3512755e240c649e67655ed6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Karnok?= Date: Mon, 17 Jun 2019 20:10:57 +0200 Subject: [PATCH 3/3] Some cleanup --- src/main/java/io/reactivex/Flowable.java | 6 +++--- .../java/io/reactivex/internal/functions/Functions.java | 4 ++-- .../java/io/reactivex/internal/fuseable/ScalarSupplier.java | 2 +- .../internal/operators/single/SingleInternalHelper.java | 2 +- .../reactivex/internal/util/AppendOnlyLinkedArrayList.java | 2 +- .../internal/operators/flowable/FlowableBufferTest.java | 1 + .../internal/operators/flowable/FlowableReplayTest.java | 4 ++-- .../internal/operators/observable/ObservableBufferTest.java | 1 + .../internal/operators/observable/ObservableReplayTest.java | 4 ++-- 9 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/java/io/reactivex/Flowable.java b/src/main/java/io/reactivex/Flowable.java index 6411e3dd0c..601132a188 100644 --- a/src/main/java/io/reactivex/Flowable.java +++ b/src/main/java/io/reactivex/Flowable.java @@ -89,7 +89,7 @@ * *

* The Reactive Streams specification is relatively strict when defining interactions between {@code Publisher}s and {@code Subscriber}s, so much so - * that there is a significant performance penalty due certain timing requirements and the need to prepare for invalid + * that there is a significant performance penalty due certain timing requirements and the need to prepare for invalid * request amounts via {@link Subscription#request(long)}. * Therefore, RxJava has introduced the {@link FlowableSubscriber} interface that indicates the consumer can be driven with relaxed rules. * All RxJava operators are implemented with these relaxed rules in mind. @@ -112,7 +112,7 @@ * * // could be some blocking operation * Thread.sleep(1000); - * + * * // the consumer might have cancelled the flow * if (emitter.isCancelled() { * return; @@ -138,7 +138,7 @@ * RxJava reactive sources, such as {@code Flowable}, are generally synchronous and sequential in nature. In the ReactiveX design, the location (thread) * where operators run is orthogonal to when the operators can work with data. This means that asynchrony and parallelism * has to be explicitly expressed via operators such as {@link #subscribeOn(Scheduler)}, {@link #observeOn(Scheduler)} and {@link #parallel()}. In general, - * operators featuring a {@link Scheduler} parameter are introducing this type of asynchrony into the flow. + * operators featuring a {@link Scheduler} parameter are introducing this type of asynchrony into the flow. *

* For more information see the ReactiveX * documentation. diff --git a/src/main/java/io/reactivex/internal/functions/Functions.java b/src/main/java/io/reactivex/internal/functions/Functions.java index 8247648331..632084b075 100644 --- a/src/main/java/io/reactivex/internal/functions/Functions.java +++ b/src/main/java/io/reactivex/internal/functions/Functions.java @@ -187,7 +187,7 @@ public U call() throws Exception { public U apply(T t) throws Exception { return value; } - + @Override public U get() throws Throwable { return value; @@ -749,7 +749,7 @@ static final class NullProvider implements Callable, Supplier { public Object call() { return null; } - + @Override public Object get() throws Throwable { return null; diff --git a/src/main/java/io/reactivex/internal/fuseable/ScalarSupplier.java b/src/main/java/io/reactivex/internal/fuseable/ScalarSupplier.java index cc5abbab18..4d51b11640 100644 --- a/src/main/java/io/reactivex/internal/fuseable/ScalarSupplier.java +++ b/src/main/java/io/reactivex/internal/fuseable/ScalarSupplier.java @@ -20,7 +20,7 @@ * safely extracted during assembly time can be used for * optimization. *

- * Implementors of {@link #call()} should not throw any exception. + * Implementors of {@link #get()} should not throw any exception. *

* Design note: the interface extends {@link Supplier} because if a scalar * is safe to extract during assembly time, it is also safe to extract at diff --git a/src/main/java/io/reactivex/internal/operators/single/SingleInternalHelper.java b/src/main/java/io/reactivex/internal/operators/single/SingleInternalHelper.java index e4345635ce..e0be7d2958 100644 --- a/src/main/java/io/reactivex/internal/operators/single/SingleInternalHelper.java +++ b/src/main/java/io/reactivex/internal/operators/single/SingleInternalHelper.java @@ -39,7 +39,7 @@ enum NoSuchElementCallable implements Supplier, Callable public NoSuchElementException call() throws Exception { return new NoSuchElementException(); } - + @Override public NoSuchElementException get() throws Throwable { return new NoSuchElementException(); diff --git a/src/main/java/io/reactivex/internal/util/AppendOnlyLinkedArrayList.java b/src/main/java/io/reactivex/internal/util/AppendOnlyLinkedArrayList.java index ed2c02ae23..0776c6e237 100644 --- a/src/main/java/io/reactivex/internal/util/AppendOnlyLinkedArrayList.java +++ b/src/main/java/io/reactivex/internal/util/AppendOnlyLinkedArrayList.java @@ -158,7 +158,7 @@ public boolean accept(Observer observer) { * @param the extra state type * @param state the extra state passed into the consumer * @param consumer the consumer of values that returns true if the forEach should terminate - * @throws Exception if the predicate throws + * @throws Throwable if the predicate throws */ @SuppressWarnings("unchecked") public void forEachWhile(S state, BiPredicate consumer) throws Throwable { diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableBufferTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableBufferTest.java index 920958fb91..21c25202d4 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableBufferTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableBufferTest.java @@ -2771,6 +2771,7 @@ public void timedSizeBufferAlreadyCleared() { } @Test + @SuppressWarnings("unchecked") public void bufferExactFailingSupplier() { Flowable.empty() .buffer(1, TimeUnit.SECONDS, Schedulers.computation(), 10, new Supplier>() { diff --git a/src/test/java/io/reactivex/internal/operators/flowable/FlowableReplayTest.java b/src/test/java/io/reactivex/internal/operators/flowable/FlowableReplayTest.java index 04f7b3dc8f..06a9bad237 100644 --- a/src/test/java/io/reactivex/internal/operators/flowable/FlowableReplayTest.java +++ b/src/test/java/io/reactivex/internal/operators/flowable/FlowableReplayTest.java @@ -558,7 +558,7 @@ public void testIssue2191_UnsubscribeSource() throws Throwable { /** * Specifically test interaction with a Scheduler with subscribeOn. * - * @throws Exception functional interfaces declare throws Exception + * @throws Throwable functional interfaces declare throws Exception */ @SuppressWarnings("unchecked") @Test @@ -618,7 +618,7 @@ public void testIssue2191_SchedulerUnsubscribe() throws Throwable { /** * Specifically test interaction with a Scheduler with subscribeOn. * - * @throws Exception functional interfaces declare throws Exception + * @throws Throwable functional interfaces declare throws Exception */ @SuppressWarnings("unchecked") @Test diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableBufferTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableBufferTest.java index a69f9998e9..97dd5e58da 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableBufferTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableBufferTest.java @@ -2138,6 +2138,7 @@ public ObservableSource> apply(Observable o) } @Test + @SuppressWarnings("unchecked") public void bufferExactFailingSupplier() { Observable.empty() .buffer(1, TimeUnit.SECONDS, Schedulers.computation(), 10, new Supplier>() { diff --git a/src/test/java/io/reactivex/internal/operators/observable/ObservableReplayTest.java b/src/test/java/io/reactivex/internal/operators/observable/ObservableReplayTest.java index 720596f4fa..208d6d0cc0 100644 --- a/src/test/java/io/reactivex/internal/operators/observable/ObservableReplayTest.java +++ b/src/test/java/io/reactivex/internal/operators/observable/ObservableReplayTest.java @@ -558,7 +558,7 @@ public void testIssue2191_UnsubscribeSource() throws Throwable { /** * Specifically test interaction with a Scheduler with subscribeOn. * - * @throws Exception functional interfaces are declared with throws Exception + * @throws Throwable functional interfaces are declared with throws Exception */ @SuppressWarnings("unchecked") @Test @@ -611,7 +611,7 @@ public void testIssue2191_SchedulerUnsubscribe() throws Throwable { /** * Specifically test interaction with a Scheduler with subscribeOn. * - * @throws Exception functional interfaces are declared with throws Exception + * @throws Throwable functional interfaces are declared with throws Exception */ @SuppressWarnings("unchecked") @Test