Skip to content

Commit

Permalink
2.x: additional warnings for fromPublisher()
Browse files Browse the repository at this point in the history
  • Loading branch information
akarnokd committed Oct 4, 2017
1 parent 3e11dc0 commit ef611ab
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/main/java/io/reactivex/Completable.java
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,17 @@ public static <T> Completable fromObservable(final ObservableSource<T> observabl
/**
* Returns a Completable instance that subscribes to the given publisher, ignores all values and
* emits only the terminal event.
* <p>
* The {@link Publisher} must follow the
* <a href="https://github.com/reactive-streams/reactive-streams-jvm#reactive-streams">Reactive-Streams specification</a>.
* Violating the specification may result in undefined behavior.
* <p>
* If possible, use {@link #create(CompletableOnSubscribe)} to create a
* source-like {@code Completable} instead.
* <p>
* Note that even though {@link Publisher} appears to be a functional interface, it
* is not recommended to implement it through a lambda as the specification requires
* state management not achievable with a stateless lambda.
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>The returned {@code Completable} honors the backpressure of the downstream consumer
Expand All @@ -405,6 +416,7 @@ public static <T> Completable fromObservable(final ObservableSource<T> observabl
* @param publisher the Publisher instance to subscribe to, not null
* @return the new Completable instance
* @throws NullPointerException if publisher is null
* @see #create(CompletableOnSubscribe)
*/
@CheckReturnValue
@BackpressureSupport(BackpressureKind.UNBOUNDED_IN)
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/io/reactivex/Flowable.java
Original file line number Diff line number Diff line change
Expand Up @@ -2094,6 +2094,17 @@ public static <T> Flowable<T> fromIterable(Iterable<? extends T> source) {
/**
* Converts an arbitrary Reactive-Streams Publisher into a Flowable if not already a
* Flowable.
* <p>
* The {@link Publisher} must follow the
* <a href="https://github.com/reactive-streams/reactive-streams-jvm#reactive-streams">Reactive-Streams specification</a>.
* Violating the specification may result in undefined behavior.
* <p>
* If possible, use {@link #create(FlowableOnSubscribe, BackpressureStrategy)} to create a
* source-like {@code Flowable} instead.
* <p>
* Note that even though {@link Publisher} appears to be a functional interface, it
* is not recommended to implement it through a lambda as the specification requires
* state management not achievable with a stateless lambda.
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>The operator is a pass-through for backpressure and its behavior is determined by the
Expand All @@ -2105,6 +2116,7 @@ public static <T> Flowable<T> fromIterable(Iterable<? extends T> source) {
* @param source the Publisher to convert
* @return the new Flowable instance
* @throws NullPointerException if publisher is null
* @see #create(FlowableOnSubscribe, BackpressureStrategy)
*/
@CheckReturnValue
@BackpressureSupport(BackpressureKind.PASS_THROUGH)
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/io/reactivex/Observable.java
Original file line number Diff line number Diff line change
Expand Up @@ -1897,6 +1897,17 @@ public static <T> Observable<T> fromIterable(Iterable<? extends T> source) {

/**
* Converts an arbitrary Reactive-Streams Publisher into an Observable.
* <p>
* The {@link Publisher} must follow the
* <a href="https://github.com/reactive-streams/reactive-streams-jvm#reactive-streams">Reactive-Streams specification</a>.
* Violating the specification may result in undefined behavior.
* <p>
* If possible, use {@link #create(ObservableOnSubscribe)} to create a
* source-like {@code Observable} instead.
* <p>
* Note that even though {@link Publisher} appears to be a functional interface, it
* is not recommended to implement it through a lambda as the specification requires
* state management not achievable with a stateless lambda.
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>The source {@code publisher} is consumed in an unbounded fashion without applying any
Expand All @@ -1908,6 +1919,7 @@ public static <T> Observable<T> fromIterable(Iterable<? extends T> source) {
* @param publisher the Publisher to convert
* @return the new Observable instance
* @throws NullPointerException if publisher is null
* @see #create(ObservableOnSubscribe)
*/
@BackpressureSupport(BackpressureKind.UNBOUNDED_IN)
@CheckReturnValue
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/io/reactivex/Single.java
Original file line number Diff line number Diff line change
Expand Up @@ -578,6 +578,17 @@ public static <T> Single<T> fromFuture(Future<? extends T> future, Scheduler sch
* Wraps a specific Publisher into a Single and signals its single element or error.
* <p>If the source Publisher is empty, a NoSuchElementException is signalled. If
* the source has more than one element, an IndexOutOfBoundsException is signalled.
* <p>
* The {@link Publisher} must follow the
* <a href="https://github.com/reactive-streams/reactive-streams-jvm#reactive-streams">Reactive-Streams specification</a>.
* Violating the specification may result in undefined behavior.
* <p>
* If possible, use {@link #create(SingleOnSubscribe)} to create a
* source-like {@code Single} instead.
* <p>
* Note that even though {@link Publisher} appears to be a functional interface, it
* is not recommended to implement it through a lambda as the specification requires
* state management not achievable with a stateless lambda.
* <dl>
* <dt><b>Backpressure:</b></dt>
* <dd>The {@code publisher} is consumed in an unbounded fashion but will be cancelled
Expand All @@ -588,6 +599,7 @@ public static <T> Single<T> fromFuture(Future<? extends T> future, Scheduler sch
* @param <T> the value type
* @param publisher the source Publisher instance, not null
* @return the new Single instance
* @see #create(SingleOnSubscribe)
*/
@BackpressureSupport(BackpressureKind.UNBOUNDED_IN)
@CheckReturnValue
Expand Down

0 comments on commit ef611ab

Please sign in to comment.