Skip to content

Commit 9e2fa63

Browse files
authored
3.x: Remove fromFuture(..., Scheduler) overloads (#6814)
1 parent 45c0b06 commit 9e2fa63

File tree

11 files changed

+9
-284
lines changed

11 files changed

+9
-284
lines changed

Diff for: src/main/java/io/reactivex/rxjava3/core/Flowable.java

-89
Original file line numberDiff line numberDiff line change
@@ -2089,95 +2089,6 @@ public static <T> Flowable<T> error(@NonNull Throwable throwable) {
20892089
return RxJavaPlugins.onAssembly(new FlowableFromFuture<>(future, timeout, unit));
20902090
}
20912091

2092-
/**
2093-
* Converts a {@link Future} into a {@link Publisher}, with a timeout on the {@code Future}.
2094-
* <p>
2095-
* <img width="640" height="315" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/from.Future.png" alt="">
2096-
* <p>
2097-
* You can convert any object that supports the {@code Future} interface into a {@code Publisher} that emits the
2098-
* return value of the {@link Future#get} method of that object by passing the object into the {@code from}
2099-
* method.
2100-
* <p>
2101-
* Unlike 1.x, canceling the {@code Flowable} won't cancel the future. If necessary, one can use composition to achieve the
2102-
* cancellation effect: {@code futurePublisher.doOnCancel(() -> future.cancel(true));}.
2103-
* <p>
2104-
* <em>Important note:</em> This {@code Publisher} is blocking; you cannot cancel it.
2105-
* <p>
2106-
* Also note that this operator will consume a {@link CompletionStage}-based {@code Future} subclass (such as
2107-
* {@link CompletableFuture}) in a blocking manner as well. Use the {@link #fromCompletionStage(CompletionStage)}
2108-
* operator to convert and consume such sources in a non-blocking fashion instead.
2109-
* <dl>
2110-
* <dt><b>Backpressure:</b></dt>
2111-
* <dd>The operator honors backpressure from downstream.</dd>
2112-
* <dt><b>Scheduler:</b></dt>
2113-
* <dd>{@code fromFuture} does not operate by default on a particular {@link Scheduler}.</dd>
2114-
* </dl>
2115-
*
2116-
* @param future
2117-
* the source {@code Future}
2118-
* @param timeout
2119-
* the maximum time to wait before calling {@code get}
2120-
* @param unit
2121-
* the {@link TimeUnit} of the {@code timeout} argument
2122-
* @param scheduler
2123-
* the {@code Scheduler} to wait for the {@code Future} on. Use a {@code Scheduler} such as
2124-
* {@link Schedulers#io()} that can block and wait on the {@code Future}
2125-
* @param <T>
2126-
* the type of object that the {@code Future} returns, and also the type of item to be emitted by
2127-
* the resulting {@code Publisher}
2128-
* @return a {@code Flowable} that emits the item from the source {@code Future}
2129-
* @see <a href="http://reactivex.io/documentation/operators/from.html">ReactiveX operators documentation: From</a>
2130-
* @see #fromCompletionStage(CompletionStage)
2131-
*/
2132-
@SuppressWarnings({ "unchecked" })
2133-
@CheckReturnValue
2134-
@NonNull
2135-
@BackpressureSupport(BackpressureKind.FULL)
2136-
@SchedulerSupport(SchedulerSupport.CUSTOM)
2137-
public static <@NonNull T> Flowable<T> fromFuture(Future<? extends T> future, long timeout, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) {
2138-
Objects.requireNonNull(scheduler, "scheduler is null");
2139-
return fromFuture((Future<T>)future, timeout, unit).subscribeOn(scheduler);
2140-
}
2141-
2142-
/**
2143-
* Converts a {@link Future}, operating on a specified {@link Scheduler}, into a {@link Publisher}.
2144-
* <p>
2145-
* <img width="640" height="315" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/from.Future.s.png" alt="">
2146-
* <p>
2147-
* You can convert any object that supports the {@code Future} interface into a {@code Publisher} that emits the
2148-
* return value of the {@link Future#get} method of that object by passing the object into the {@code from}
2149-
* method.
2150-
* <p>
2151-
* Unlike 1.x, canceling the {@code Flowable} won't cancel the future. If necessary, one can use composition to achieve the
2152-
* cancellation effect: {@code futurePublisher.doOnCancel(() -> future.cancel(true));}.
2153-
* <dl>
2154-
* <dt><b>Backpressure:</b></dt>
2155-
* <dd>The operator honors backpressure from downstream.</dd>
2156-
* <dt><b>Scheduler:</b></dt>
2157-
* <dd>You specify which {@code Scheduler} this operator will use.</dd>
2158-
* </dl>
2159-
*
2160-
* @param future
2161-
* the source {@code Future}
2162-
* @param scheduler
2163-
* the {@code Scheduler} to wait for the {@code Future} on. Use a {@code Scheduler} such as
2164-
* {@link Schedulers#io()} that can block and wait on the {@code Future}
2165-
* @param <T>
2166-
* the type of object that the {@code Future} returns, and also the type of item to be emitted by
2167-
* the resulting {@code Publisher}
2168-
* @return a {@code Flowable} that emits the item from the source {@code Future}
2169-
* @see <a href="http://reactivex.io/documentation/operators/from.html">ReactiveX operators documentation: From</a>
2170-
*/
2171-
@SuppressWarnings({ "unchecked" })
2172-
@CheckReturnValue
2173-
@NonNull
2174-
@BackpressureSupport(BackpressureKind.FULL)
2175-
@SchedulerSupport(SchedulerSupport.CUSTOM)
2176-
public static <@NonNull T> Flowable<T> fromFuture(Future<? extends T> future, @NonNull Scheduler scheduler) {
2177-
Objects.requireNonNull(scheduler, "scheduler is null");
2178-
return fromFuture((Future<T>)future).subscribeOn(scheduler);
2179-
}
2180-
21812092
/**
21822093
* Converts an {@link Iterable} sequence into a {@link Publisher} that emits the items in the sequence.
21832094
* <p>

Diff for: src/main/java/io/reactivex/rxjava3/core/Observable.java

-78
Original file line numberDiff line numberDiff line change
@@ -1839,84 +1839,6 @@ public static <T> Observable<T> fromFuture(@NonNull Future<? extends T> future,
18391839
return RxJavaPlugins.onAssembly(new ObservableFromFuture<>(future, timeout, unit));
18401840
}
18411841

1842-
/**
1843-
* Converts a {@link Future} into an ObservableSource, with a timeout on the Future.
1844-
* <p>
1845-
* <img width="640" height="287" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/fromFuture.timeout.scheduler.png" alt="">
1846-
* <p>
1847-
* You can convert any object that supports the {@link Future} interface into an ObservableSource that emits the
1848-
* return value of the {@link Future#get} method of that object, by passing the object into the {@code from}
1849-
* method.
1850-
* <p>
1851-
* Unlike 1.x, disposing the Observable won't cancel the future. If necessary, one can use composition to achieve the
1852-
* cancellation effect: {@code futureObservableSource.doOnDispose(() -> future.cancel(true));}.
1853-
* <p>
1854-
* <em>Important note:</em> This ObservableSource is blocking; you cannot dispose it.
1855-
* <dl>
1856-
* <dt><b>Scheduler:</b></dt>
1857-
* <dd>{@code fromFuture} does not operate by default on a particular {@link Scheduler}.</dd>
1858-
* </dl>
1859-
*
1860-
* @param future
1861-
* the source {@link Future}
1862-
* @param timeout
1863-
* the maximum time to wait before calling {@code get}
1864-
* @param unit
1865-
* the {@link TimeUnit} of the {@code timeout} argument
1866-
* @param scheduler
1867-
* the {@link Scheduler} to wait for the Future on. Use a Scheduler such as
1868-
* {@link Schedulers#io()} that can block and wait on the Future
1869-
* @param <T>
1870-
* the type of object that the {@link Future} returns, and also the type of item to be emitted by
1871-
* the resulting ObservableSource
1872-
* @return an Observable that emits the item from the source {@link Future}
1873-
* @see <a href="http://reactivex.io/documentation/operators/from.html">ReactiveX operators documentation: From</a>
1874-
*/
1875-
@CheckReturnValue
1876-
@NonNull
1877-
@SchedulerSupport(SchedulerSupport.CUSTOM)
1878-
public static <T> Observable<T> fromFuture(@NonNull Future<? extends T> future, long timeout, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) {
1879-
Objects.requireNonNull(scheduler, "scheduler is null");
1880-
Observable<T> o = fromFuture(future, timeout, unit);
1881-
return o.subscribeOn(scheduler);
1882-
}
1883-
1884-
/**
1885-
* Converts a {@link Future}, operating on a specified {@link Scheduler}, into an ObservableSource.
1886-
* <p>
1887-
* <img width="640" height="294" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/fromFuture.scheduler.png" alt="">
1888-
* <p>
1889-
* You can convert any object that supports the {@link Future} interface into an ObservableSource that emits the
1890-
* return value of the {@link Future#get} method of that object, by passing the object into the {@code from}
1891-
* method.
1892-
* <p>
1893-
* Unlike 1.x, disposing the Observable won't cancel the future. If necessary, one can use composition to achieve the
1894-
* cancellation effect: {@code futureObservableSource.doOnDispose(() -> future.cancel(true));}.
1895-
* <dl>
1896-
* <dt><b>Scheduler:</b></dt>
1897-
* <dd>You specify which {@link Scheduler} this operator will use.</dd>
1898-
* </dl>
1899-
*
1900-
* @param future
1901-
* the source {@link Future}
1902-
* @param scheduler
1903-
* the {@link Scheduler} to wait for the Future on. Use a Scheduler such as
1904-
* {@link Schedulers#io()} that can block and wait on the Future
1905-
* @param <T>
1906-
* the type of object that the {@link Future} returns, and also the type of item to be emitted by
1907-
* the resulting ObservableSource
1908-
* @return an Observable that emits the item from the source {@link Future}
1909-
* @see <a href="http://reactivex.io/documentation/operators/from.html">ReactiveX operators documentation: From</a>
1910-
*/
1911-
@CheckReturnValue
1912-
@NonNull
1913-
@SchedulerSupport(SchedulerSupport.CUSTOM)
1914-
public static <T> Observable<T> fromFuture(@NonNull Future<? extends T> future, @NonNull Scheduler scheduler) {
1915-
Objects.requireNonNull(scheduler, "scheduler is null");
1916-
Observable<T> o = fromFuture(future);
1917-
return o.subscribeOn(scheduler);
1918-
}
1919-
19201842
/**
19211843
* Converts an {@link Iterable} sequence into an ObservableSource that emits the items in the sequence.
19221844
* <p>

Diff for: src/main/java/io/reactivex/rxjava3/core/Single.java

-67
Original file line numberDiff line numberDiff line change
@@ -722,73 +722,6 @@ public static <T> Single<T> error(@NonNull Throwable exception) {
722722
return toSingle(Flowable.fromFuture(future, timeout, unit));
723723
}
724724

725-
/**
726-
* Converts a {@link Future} into a {@code Single}, with a timeout on the {@code Future}.
727-
* <p>
728-
* <img width="640" height="315" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Single.from.Future.png" alt="">
729-
* <p>
730-
* You can convert any object that supports the {@code Future} interface into a {@code Single} that emits
731-
* the return value of the {@link Future#get} method of that object, by passing the object into the
732-
* {@code from} method.
733-
* <p>
734-
* <em>Important note:</em> This {@code Single} is blocking; you cannot dispose it.
735-
* <dl>
736-
* <dt><b>Scheduler:</b></dt>
737-
* <dd>You specify the {@link Scheduler} where the blocking wait will happen.</dd>
738-
* </dl>
739-
*
740-
* @param future
741-
* the source {@code Future}
742-
* @param timeout
743-
* the maximum time to wait before calling {@code get}
744-
* @param unit
745-
* the {@link TimeUnit} of the {@code timeout} argument
746-
* @param scheduler
747-
* the {@code Scheduler} to use for the blocking wait
748-
* @param <T>
749-
* the type of object that the {@code Future} returns, and also the type of item to be emitted by
750-
* the resulting {@code Single}
751-
* @return the new {@code Single} that emits the item from the source {@code Future}
752-
* @see <a href="http://reactivex.io/documentation/operators/from.html">ReactiveX operators documentation: From</a>
753-
*/
754-
@CheckReturnValue
755-
@SchedulerSupport(SchedulerSupport.CUSTOM)
756-
@NonNull
757-
public static <@NonNull T> Single<T> fromFuture(@NonNull Future<? extends T> future, long timeout, @NonNull TimeUnit unit, @NonNull Scheduler scheduler) {
758-
return toSingle(Flowable.fromFuture(future, timeout, unit, scheduler));
759-
}
760-
761-
/**
762-
* Converts a {@link Future}, operating on a specified {@link Scheduler}, into a {@code Single}.
763-
* <p>
764-
* <img width="640" height="315" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/Single.from.Future.s.png" alt="">
765-
* <p>
766-
* You can convert any object that supports the {@code Future} interface into a {@code Single} that emits
767-
* the return value of the {@link Future#get} method of that object, by passing the object into the
768-
* {@code from} method.
769-
* <dl>
770-
* <dt><b>Scheduler:</b></dt>
771-
* <dd>You specify which {@code Scheduler} this operator will use.</dd>
772-
* </dl>
773-
*
774-
* @param future
775-
* the source {@code Future}
776-
* @param scheduler
777-
* the {@code Scheduler} to wait for the {@code Future} on. Use a {@code Scheduler} such as
778-
* {@link Schedulers#io()} that can block and wait on the {@code Future}
779-
* @param <T>
780-
* the type of object that the {@code Future} returns, and also the type of item to be emitted by
781-
* the resulting {@code Single}
782-
* @return the new {@code Single} that emits the item from the source {@code Future}
783-
* @see <a href="http://reactivex.io/documentation/operators/from.html">ReactiveX operators documentation: From</a>
784-
*/
785-
@CheckReturnValue
786-
@SchedulerSupport(SchedulerSupport.CUSTOM)
787-
@NonNull
788-
public static <@NonNull T> Single<T> fromFuture(@NonNull Future<? extends T> future, @NonNull Scheduler scheduler) {
789-
return toSingle(Flowable.fromFuture(future, scheduler));
790-
}
791-
792725
/**
793726
* Wraps a specific {@link Publisher} into a {@code Single} and signals its single element or error.
794727
* <p>

Diff for: src/test/java/io/reactivex/rxjava3/flowable/FlowableNullTests.java

-10
Original file line numberDiff line numberDiff line change
@@ -252,23 +252,13 @@ public void fromFutureTimedUnitNull() {
252252
Flowable.fromFuture(new FutureTask<>(Functions.EMPTY_RUNNABLE, null), 1, null);
253253
}
254254

255-
@Test(expected = NullPointerException.class)
256-
public void fromFutureTimedSchedulerNull() {
257-
Flowable.fromFuture(new FutureTask<>(Functions.EMPTY_RUNNABLE, null), 1, TimeUnit.SECONDS, null);
258-
}
259-
260255
@Test(expected = NullPointerException.class)
261256
public void fromFutureTimedReturnsNull() {
262257
FutureTask<Object> f = new FutureTask<>(Functions.EMPTY_RUNNABLE, null);
263258
f.run();
264259
Flowable.fromFuture(f, 1, TimeUnit.SECONDS).blockingLast();
265260
}
266261

267-
@Test(expected = NullPointerException.class)
268-
public void fromFutureSchedulerNull() {
269-
Flowable.fromFuture(new FutureTask<>(Functions.EMPTY_RUNNABLE, null), null);
270-
}
271-
272262
@Test(expected = NullPointerException.class)
273263
public void fromIterableNull() {
274264
Flowable.fromIterable(null);

Diff for: src/test/java/io/reactivex/rxjava3/internal/operators/flowable/FlowableToFutureTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void successOperatesOnSuppliedScheduler() throws Exception {
6262
TestScheduler scheduler = new TestScheduler();
6363
TestSubscriber<Object> ts = new TestSubscriber<>(subscriber);
6464

65-
Flowable.fromFuture(future, scheduler).subscribe(ts);
65+
Flowable.fromFuture(future).subscribeOn(scheduler).subscribe(ts);
6666

6767
verify(subscriber, never()).onNext(value);
6868

@@ -234,7 +234,7 @@ public void run() {
234234

235235
TestSubscriber<Integer> ts = TestSubscriber.create();
236236

237-
Flowable.fromFuture(task, Schedulers.computation()).subscribe(ts);
237+
Flowable.fromFuture(task).subscribeOn(Schedulers.computation()).subscribe(ts);
238238

239239
task.run();
240240

Diff for: src/test/java/io/reactivex/rxjava3/internal/operators/observable/ObservableFromTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ public class ObservableFromTest extends RxJavaTest {
3030
@Test
3131
public void fromFutureTimeout() throws Exception {
3232
Observable.fromFuture(Observable.never()
33-
.toFuture(), 100, TimeUnit.MILLISECONDS, Schedulers.io())
33+
.toFuture(), 100, TimeUnit.MILLISECONDS)
34+
.subscribeOn(Schedulers.io())
3435
.test()
3536
.awaitDone(5, TimeUnit.SECONDS)
3637
.assertFailure(TimeoutException.class);

Diff for: src/test/java/io/reactivex/rxjava3/internal/operators/observable/ObservableToFutureTest.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void successOperatesOnSuppliedScheduler() throws Exception {
6161
TestScheduler scheduler = new TestScheduler();
6262
TestObserver<Object> to = new TestObserver<>(o);
6363

64-
Observable.fromFuture(future, scheduler).subscribe(to);
64+
Observable.fromFuture(future).subscribeOn(scheduler).subscribe(to);
6565

6666
verify(o, never()).onNext(value);
6767

Diff for: src/test/java/io/reactivex/rxjava3/internal/operators/single/SingleFromTest.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,17 @@ public class SingleFromTest extends RxJavaTest {
2424

2525
@Test
2626
public void fromFuture() throws Exception {
27-
Single.fromFuture(Flowable.just(1).toFuture(), Schedulers.io())
27+
Single.fromFuture(Flowable.just(1).toFuture())
28+
.subscribeOn(Schedulers.io())
2829
.test()
2930
.awaitDone(5, TimeUnit.SECONDS)
3031
.assertResult(1);
3132
}
3233

3334
@Test
3435
public void fromFutureTimeout() throws Exception {
35-
Single.fromFuture(Flowable.never().toFuture(), 1, TimeUnit.SECONDS, Schedulers.io())
36+
Single.fromFuture(Flowable.never().toFuture(), 1, TimeUnit.SECONDS)
37+
.subscribeOn(Schedulers.io())
3638
.test()
3739
.awaitDone(5, TimeUnit.SECONDS)
3840
.assertFailure(TimeoutException.class);

Diff for: src/test/java/io/reactivex/rxjava3/observable/ObservableNullTests.java

-11
Original file line numberDiff line numberDiff line change
@@ -299,24 +299,13 @@ public void fromFutureTimedUnitNull() {
299299
Observable.fromFuture(new FutureTask<>(Functions.EMPTY_RUNNABLE, null), 1, null);
300300
}
301301

302-
@Test(expected = NullPointerException.class)
303-
public void fromFutureTimedSchedulerNull() {
304-
Observable.fromFuture(new FutureTask<>(Functions.EMPTY_RUNNABLE, null), 1, TimeUnit.SECONDS, null);
305-
}
306-
307302
@Test(expected = NullPointerException.class)
308303
public void fromFutureTimedReturnsNull() {
309304
FutureTask<Object> f = new FutureTask<>(Functions.EMPTY_RUNNABLE, null);
310305
f.run();
311306
Observable.fromFuture(f, 1, TimeUnit.SECONDS).blockingLast();
312307
}
313308

314-
@Test(expected = NullPointerException.class)
315-
public void fromFutureSchedulerNull() {
316-
FutureTask<Object> f = new FutureTask<>(Functions.EMPTY_RUNNABLE, null);
317-
Observable.fromFuture(f, null);
318-
}
319-
320309
@Test(expected = NullPointerException.class)
321310
public void fromIterableNull() {
322311
Observable.fromIterable(null);

Diff for: src/test/java/io/reactivex/rxjava3/single/SingleNullTests.java

-20
Original file line numberDiff line numberDiff line change
@@ -194,33 +194,13 @@ public Object call() throws Exception {
194194
}), 1, null);
195195
}
196196

197-
@Test(expected = NullPointerException.class)
198-
public void fromFutureTimedSchedulerNull() {
199-
Single.fromFuture(new FutureTask<>(new Callable<Object>() {
200-
@Override
201-
public Object call() throws Exception {
202-
return null;
203-
}
204-
}), 1, TimeUnit.SECONDS, null);
205-
}
206-
207197
@Test(expected = NullPointerException.class)
208198
public void fromFutureTimedReturnsNull() {
209199
FutureTask<Object> f = new FutureTask<>(Functions.EMPTY_RUNNABLE, null);
210200
f.run();
211201
Single.fromFuture(f, 1, TimeUnit.SECONDS).blockingGet();
212202
}
213203

214-
@Test(expected = NullPointerException.class)
215-
public void fromFutureSchedulerNull() {
216-
Single.fromFuture(new FutureTask<>(new Callable<Object>() {
217-
@Override
218-
public Object call() throws Exception {
219-
return null;
220-
}
221-
}), null);
222-
}
223-
224204
@Test(expected = NullPointerException.class)
225205
public void fromPublisherNull() {
226206
Single.fromPublisher(null);

0 commit comments

Comments
 (0)