Skip to content

Commit d57af5a

Browse files
authored
2.x: Add blockingSubscribe JavaDoc clarifications (#5984)
1 parent 59cf89c commit d57af5a

File tree

2 files changed

+66
-6
lines changed

2 files changed

+66
-6
lines changed

src/main/java/io/reactivex/Flowable.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5801,6 +5801,10 @@ public final Future<T> toFuture() {
58015801

58025802
/**
58035803
* Runs the source Flowable to a terminal event, ignoring any values and rethrowing any exception.
5804+
* <p>
5805+
* Note that calling this method will block the caller thread until the upstream terminates
5806+
* normally or with an error. Therefore, calling this method from special threads such as the
5807+
* Android Main Thread or the Swing Event Dispatch Thread is not recommended.
58045808
* <dl>
58055809
* <dt><b>Backpressure:</b></dt>
58065810
* <dd>The operator consumes the source {@code Flowable} in an unbounded manner
@@ -5809,6 +5813,9 @@ public final Future<T> toFuture() {
58095813
* <dd>{@code blockingSubscribe} does not operate by default on a particular {@link Scheduler}.</dd>
58105814
* </dl>
58115815
* @since 2.0
5816+
* @see #blockingSubscribe(Consumer)
5817+
* @see #blockingSubscribe(Consumer, Consumer)
5818+
* @see #blockingSubscribe(Consumer, Consumer, Action)
58125819
*/
58135820
@BackpressureSupport(BackpressureKind.UNBOUNDED_IN)
58145821
@SchedulerSupport(SchedulerSupport.NONE)
@@ -5822,6 +5829,12 @@ public final void blockingSubscribe() {
58225829
* If the Flowable emits an error, it is wrapped into an
58235830
* {@link io.reactivex.exceptions.OnErrorNotImplementedException OnErrorNotImplementedException}
58245831
* and routed to the RxJavaPlugins.onError handler.
5832+
* Using the overloads {@link #blockingSubscribe(Consumer, Consumer)}
5833+
* or {@link #blockingSubscribe(Consumer, Consumer, Action)} instead is recommended.
5834+
* <p>
5835+
* Note that calling this method will block the caller thread until the upstream terminates
5836+
* normally or with an error. Therefore, calling this method from special threads such as the
5837+
* Android Main Thread or the Swing Event Dispatch Thread is not recommended.
58255838
* <dl>
58265839
* <dt><b>Backpressure:</b></dt>
58275840
* <dd>The operator consumes the source {@code Flowable} in an unbounded manner
@@ -5831,6 +5844,8 @@ public final void blockingSubscribe() {
58315844
* </dl>
58325845
* @param onNext the callback action for each source value
58335846
* @since 2.0
5847+
* @see #blockingSubscribe(Consumer, Consumer)
5848+
* @see #blockingSubscribe(Consumer, Consumer, Action)
58345849
*/
58355850
@BackpressureSupport(BackpressureKind.UNBOUNDED_IN)
58365851
@SchedulerSupport(SchedulerSupport.NONE)
@@ -5840,6 +5855,10 @@ public final void blockingSubscribe(Consumer<? super T> onNext) {
58405855

58415856
/**
58425857
* Subscribes to the source and calls the given callbacks <strong>on the current thread</strong>.
5858+
* <p>
5859+
* Note that calling this method will block the caller thread until the upstream terminates
5860+
* normally or with an error. Therefore, calling this method from special threads such as the
5861+
* Android Main Thread or the Swing Event Dispatch Thread is not recommended.
58435862
* <dl>
58445863
* <dt><b>Backpressure:</b></dt>
58455864
* <dd>The operator consumes the source {@code Flowable} in an unbounded manner
@@ -5850,6 +5869,7 @@ public final void blockingSubscribe(Consumer<? super T> onNext) {
58505869
* @param onNext the callback action for each source value
58515870
* @param onError the callback action for an error event
58525871
* @since 2.0
5872+
* @see #blockingSubscribe(Consumer, Consumer, Action)
58535873
*/
58545874
@BackpressureSupport(BackpressureKind.UNBOUNDED_IN)
58555875
@SchedulerSupport(SchedulerSupport.NONE)
@@ -5860,6 +5880,10 @@ public final void blockingSubscribe(Consumer<? super T> onNext, Consumer<? super
58605880

58615881
/**
58625882
* Subscribes to the source and calls the given callbacks <strong>on the current thread</strong>.
5883+
* <p>
5884+
* Note that calling this method will block the caller thread until the upstream terminates
5885+
* normally or with an error. Therefore, calling this method from special threads such as the
5886+
* Android Main Thread or the Swing Event Dispatch Thread is not recommended.
58635887
* <dl>
58645888
* <dt><b>Backpressure:</b></dt>
58655889
* <dd>The operator consumes the source {@code Flowable} in an unbounded manner
@@ -5879,7 +5903,13 @@ public final void blockingSubscribe(Consumer<? super T> onNext, Consumer<? super
58795903
}
58805904

58815905
/**
5882-
* Subscribes to the source and calls the Subscriber methods <strong>on the current thread</strong>.
5906+
* Subscribes to the source and calls the {@link Subscriber} methods <strong>on the current thread</strong>.
5907+
* <p>
5908+
* Note that calling this method will block the caller thread until the upstream terminates
5909+
* normally, with an error or the {@code Subscriber} cancels the {@link Subscription} it receives via
5910+
* {@link Subscriber#onSubscribe(Subscription)}.
5911+
* Therefore, calling this method from special threads such as the
5912+
* Android Main Thread or the Swing Event Dispatch Thread is not recommended.
58835913
* <dl>
58845914
* <dt><b>Backpressure:</b></dt>
58855915
* <dd>The supplied {@code Subscriber} determines how backpressure is applied.</dd>

src/main/java/io/reactivex/Observable.java

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5314,11 +5314,18 @@ public final Future<T> toFuture() {
53145314
* Runs the source observable to a terminal event, ignoring any values and rethrowing any exception.
53155315
* <p>
53165316
* <img width="640" height="270" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/blockingSubscribe.o.0.png" alt="">
5317+
* <p>
5318+
* Note that calling this method will block the caller thread until the upstream terminates
5319+
* normally or with an error. Therefore, calling this method from special threads such as the
5320+
* Android Main Thread or the Swing Event Dispatch Thread is not recommended.
53175321
* <dl>
53185322
* <dt><b>Scheduler:</b></dt>
53195323
* <dd>{@code blockingSubscribe} does not operate by default on a particular {@link Scheduler}.</dd>
53205324
* </dl>
53215325
* @since 2.0
5326+
* @see #blockingSubscribe(Consumer)
5327+
* @see #blockingSubscribe(Consumer, Consumer)
5328+
* @see #blockingSubscribe(Consumer, Consumer, Action)
53225329
*/
53235330
@SchedulerSupport(SchedulerSupport.NONE)
53245331
public final void blockingSubscribe() {
@@ -5330,15 +5337,23 @@ public final void blockingSubscribe() {
53305337
* <p>
53315338
* <img width="640" height="393" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/blockingSubscribe.o.1.png" alt="">
53325339
* <p>
5333-
* If the Observable emits an error, it is wrapped into an
5340+
* If the {@code Observable} emits an error, it is wrapped into an
53345341
* {@link io.reactivex.exceptions.OnErrorNotImplementedException OnErrorNotImplementedException}
53355342
* and routed to the RxJavaPlugins.onError handler.
5343+
* Using the overloads {@link #blockingSubscribe(Consumer, Consumer)}
5344+
* or {@link #blockingSubscribe(Consumer, Consumer, Action)} instead is recommended.
5345+
* <p>
5346+
* Note that calling this method will block the caller thread until the upstream terminates
5347+
* normally or with an error. Therefore, calling this method from special threads such as the
5348+
* Android Main Thread or the Swing Event Dispatch Thread is not recommended.
53365349
* <dl>
53375350
* <dt><b>Scheduler:</b></dt>
53385351
* <dd>{@code blockingSubscribe} does not operate by default on a particular {@link Scheduler}.</dd>
53395352
* </dl>
53405353
* @param onNext the callback action for each source value
53415354
* @since 2.0
5355+
* @see #blockingSubscribe(Consumer, Consumer)
5356+
* @see #blockingSubscribe(Consumer, Consumer, Action)
53425357
*/
53435358
@SchedulerSupport(SchedulerSupport.NONE)
53445359
public final void blockingSubscribe(Consumer<? super T> onNext) {
@@ -5349,13 +5364,18 @@ public final void blockingSubscribe(Consumer<? super T> onNext) {
53495364
* Subscribes to the source and calls the given callbacks <strong>on the current thread</strong>.
53505365
* <p>
53515366
* <img width="640" height="396" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/blockingSubscribe.o.2.png" alt="">
5367+
* <p>
5368+
* Note that calling this method will block the caller thread until the upstream terminates
5369+
* normally or with an error. Therefore, calling this method from special threads such as the
5370+
* Android Main Thread or the Swing Event Dispatch Thread is not recommended.
53525371
* <dl>
53535372
* <dt><b>Scheduler:</b></dt>
53545373
* <dd>{@code blockingSubscribe} does not operate by default on a particular {@link Scheduler}.</dd>
53555374
* </dl>
53565375
* @param onNext the callback action for each source value
53575376
* @param onError the callback action for an error event
53585377
* @since 2.0
5378+
* @see #blockingSubscribe(Consumer, Consumer, Action)
53595379
*/
53605380
@SchedulerSupport(SchedulerSupport.NONE)
53615381
public final void blockingSubscribe(Consumer<? super T> onNext, Consumer<? super Throwable> onError) {
@@ -5367,6 +5387,10 @@ public final void blockingSubscribe(Consumer<? super T> onNext, Consumer<? super
53675387
* Subscribes to the source and calls the given callbacks <strong>on the current thread</strong>.
53685388
* <p>
53695389
* <img width="640" height="394" src="https://raw.github.com/wiki/ReactiveX/RxJava/images/rx-operators/blockingSubscribe.o.png" alt="">
5390+
* <p>
5391+
* Note that calling this method will block the caller thread until the upstream terminates
5392+
* normally or with an error. Therefore, calling this method from special threads such as the
5393+
* Android Main Thread or the Swing Event Dispatch Thread is not recommended.
53705394
* <dl>
53715395
* <dt><b>Scheduler:</b></dt>
53725396
* <dd>{@code blockingSubscribe} does not operate by default on a particular {@link Scheduler}.</dd>
@@ -5382,18 +5406,24 @@ public final void blockingSubscribe(Consumer<? super T> onNext, Consumer<? super
53825406
}
53835407

53845408
/**
5385-
* Subscribes to the source and calls the Observer methods <strong>on the current thread</strong>.
5409+
* Subscribes to the source and calls the {@link Observer} methods <strong>on the current thread</strong>.
5410+
* <p>
5411+
* Note that calling this method will block the caller thread until the upstream terminates
5412+
* normally, with an error or the {@code Observer} disposes the {@link Disposable} it receives via
5413+
* {@link Observer#onSubscribe(Disposable)}.
5414+
* Therefore, calling this method from special threads such as the
5415+
* Android Main Thread or the Swing Event Dispatch Thread is not recommended.
53865416
* <dl>
53875417
* <dt><b>Scheduler:</b></dt>
53885418
* <dd>{@code blockingSubscribe} does not operate by default on a particular {@link Scheduler}.</dd>
53895419
* </dl>
53905420
* The a dispose() call is composed through.
5391-
* @param subscriber the subscriber to forward events and calls to in the current thread
5421+
* @param observer the {@code Observer} instance to forward events and calls to in the current thread
53925422
* @since 2.0
53935423
*/
53945424
@SchedulerSupport(SchedulerSupport.NONE)
5395-
public final void blockingSubscribe(Observer<? super T> subscriber) {
5396-
ObservableBlockingSubscribe.subscribe(this, subscriber);
5425+
public final void blockingSubscribe(Observer<? super T> observer) {
5426+
ObservableBlockingSubscribe.subscribe(this, observer);
53975427
}
53985428

53995429
/**

0 commit comments

Comments
 (0)