Skip to content

Commit b0c8b42

Browse files
committed
Deprecated onBackpressureBlock.
1 parent 03332a2 commit b0c8b42

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

src/main/java/rx/Observable.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5332,14 +5332,23 @@ public final Observable<T> onBackpressureDrop() {
53325332
* <p>
53335333
* Note that if the upstream Observable does support backpressure, this operator ignores that capability
53345334
* and doesn't propagate any backpressure requests from downstream.
5335+
* <p>
5336+
* Warning! Using a chain like {@code source.onBackpressureBlock().subscribeOn(scheduler)} is prone to
5337+
* deadlocks because the consumption of the internal queue is scheduled behind a blocked emission by
5338+
* the subscribeOn. In order to avoid this, the operators have to be swapped in the chain:
5339+
* {@code source.subscribeOn(scheduler).onBackpressureBlock()} and in general, no subscribeOn operator should follow
5340+
* this operator.
53355341
*
53365342
* @param maxQueueLength the maximum number of items the producer can emit without blocking
53375343
* @return the source Observable modified to block {@code onNext} notifications on overflow
53385344
* @see <a href="http://reactivex.io/documentation/operators/backpressure.html">ReactiveX operators documentation: backpressure operators</a>
5339-
* @Experimental The behavior of this can change at any time.
5345+
* @Experimental The behavior of this can change at any time.
5346+
* @deprecated The operator doesn't work properly with {@link #subscribeOn(Scheduler)} and is prone to
5347+
* deadlocks. It will be removed/unavailable starting from 1.1.
53405348
* @since (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
53415349
*/
53425350
@Experimental
5351+
@Deprecated
53435352
public final Observable<T> onBackpressureBlock(int maxQueueLength) {
53445353
return lift(new OperatorOnBackpressureBlock<T>(maxQueueLength));
53455354
}
@@ -5355,13 +5364,22 @@ public final Observable<T> onBackpressureBlock(int maxQueueLength) {
53555364
* <p>
53565365
* Note that if the upstream Observable does support backpressure, this operator ignores that capability
53575366
* and doesn't propagate any backpressure requests from downstream.
5367+
* <p>
5368+
* Warning! Using a chain like {@code source.onBackpressureBlock().subscribeOn(scheduler)} is prone to
5369+
* deadlocks because the consumption of the internal queue is scheduled behind a blocked emission by
5370+
* the subscribeOn. In order to avoid this, the operators have to be swapped in the chain:
5371+
* {@code source.subscribeOn(scheduler).onBackpressureBlock()} and in general, no subscribeOn operator should follow
5372+
* this operator.
53585373
*
53595374
* @return the source Observable modified to block {@code onNext} notifications on overflow
53605375
* @see <a href="http://reactivex.io/documentation/operators/backpressure.html">ReactiveX operators documentation: backpressure operators</a>
53615376
* @Experimental The behavior of this can change at any time.
5377+
* @deprecated The operator doesn't work properly with {@link #subscribeOn(Scheduler)} and is prone to
5378+
* deadlocks. It will be removed/unavailable starting from 1.1.
53625379
* @since (if this graduates from Experimental/Beta to supported, replace this parenthetical with the release number)
53635380
*/
53645381
@Experimental
5382+
@Deprecated
53655383
public final Observable<T> onBackpressureBlock() {
53665384
return onBackpressureBlock(rx.internal.util.RxRingBuffer.SIZE);
53675385
}

0 commit comments

Comments
 (0)