Skip to content

Commit 899e6a8

Browse files
committed
fix forEach javadoc
1 parent 96786bb commit 899e6a8

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

src/main/java/rx/Observable.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4940,9 +4940,9 @@ public final <U, R> Observable<R> flatMapIterable(Func1<? super T, ? extends Ite
49404940
* @param onNext
49414941
* {@link Action1} to execute for each item.
49424942
* @throws IllegalArgumentException
4943-
* if {@code onNext} is null, or
4944-
* if {@code onError} is null, or
4945-
* if {@code onComplete} is null
4943+
* if {@code onNext} is null
4944+
* @throws OnErrorNotImplementedException
4945+
* if the Observable calls {@code onError}
49464946
* @see <a href="http://reactivex.io/documentation/operators/subscribe.html">ReactiveX operators documentation: Subscribe</a>
49474947
*/
49484948
public final void forEach(final Action1<? super T> onNext) {
@@ -4964,8 +4964,9 @@ public final void forEach(final Action1<? super T> onNext) {
49644964
* {@link Action1} to execute when an error is emitted.
49654965
* @throws IllegalArgumentException
49664966
* if {@code onNext} is null, or
4967-
* if {@code onError} is null, or
4968-
* if {@code onComplete} is null
4967+
* if {@code onError} is null
4968+
* @throws OnErrorNotImplementedException
4969+
* if the Observable calls {@code onError}
49694970
* @see <a href="http://reactivex.io/documentation/operators/subscribe.html">ReactiveX operators documentation: Subscribe</a>
49704971
*/
49714972
public final void forEach(final Action1<? super T> onNext, final Action1<Throwable> onError) {
@@ -4991,6 +4992,8 @@ public final void forEach(final Action1<? super T> onNext, final Action1<Throwab
49914992
* if {@code onNext} is null, or
49924993
* if {@code onError} is null, or
49934994
* if {@code onComplete} is null
4995+
* @throws OnErrorNotImplementedException
4996+
* if the Observable calls {@code onError}
49944997
* @see <a href="http://reactivex.io/documentation/operators/subscribe.html">ReactiveX operators documentation: Subscribe</a>
49954998
*/
49964999
public final void forEach(final Action1<? super T> onNext, final Action1<Throwable> onError, final Action0 onComplete) {
@@ -7485,7 +7488,7 @@ public final void onNext(T args) {
74857488
* @throws IllegalArgumentException
74867489
* if {@code onNext} is null
74877490
* @throws OnErrorNotImplementedException
7488-
* if the Observable tries to call {@code onError}
7491+
* if the Observable calls {@code onError}
74897492
* @see <a href="http://reactivex.io/documentation/operators/subscribe.html">ReactiveX operators documentation: Subscribe</a>
74907493
*/
74917494
public final Subscription subscribe(final Action1<? super T> onNext) {

src/test/java/rx/ObservableTests.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import rx.functions.Func0;
5454
import rx.functions.Func1;
5555
import rx.functions.Func2;
56+
import rx.functions.Functions;
5657
import rx.observables.ConnectableObservable;
5758
import rx.observers.TestSubscriber;
5859
import rx.schedulers.TestScheduler;
@@ -1138,4 +1139,22 @@ public void testSubscribingSubscriberAsObserverMaintainsSubscriptionChain() {
11381139

11391140
subscriber.assertUnsubscribed();
11401141
}
1142+
1143+
@Test(expected=OnErrorNotImplementedException.class)
1144+
public void testForEachWithError() {
1145+
Observable.error(new Exception("boo"))
1146+
//
1147+
.forEach(new Action1<Object>() {
1148+
@Override
1149+
public void call(Object t) {
1150+
//do nothing
1151+
}});
1152+
}
1153+
1154+
@Test(expected=IllegalArgumentException.class)
1155+
public void testForEachWithNull() {
1156+
Observable.error(new Exception("boo"))
1157+
//
1158+
.forEach(null);
1159+
}
11411160
}

0 commit comments

Comments
 (0)