Skip to content

Commit afbd89a

Browse files
committed
Merge pull request #3079 from davidmoten/foreach-javadoc
fix forEach javadoc
2 parents 06d90da + 899e6a8 commit afbd89a

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
@@ -4943,9 +4943,9 @@ public final <U, R> Observable<R> flatMapIterable(Func1<? super T, ? extends Ite
49434943
* @param onNext
49444944
* {@link Action1} to execute for each item.
49454945
* @throws IllegalArgumentException
4946-
* if {@code onNext} is null, or
4947-
* if {@code onError} is null, or
4948-
* if {@code onComplete} is null
4946+
* if {@code onNext} is null
4947+
* @throws OnErrorNotImplementedException
4948+
* if the Observable calls {@code onError}
49494949
* @see <a href="http://reactivex.io/documentation/operators/subscribe.html">ReactiveX operators documentation: Subscribe</a>
49504950
*/
49514951
public final void forEach(final Action1<? super T> onNext) {
@@ -4967,8 +4967,9 @@ public final void forEach(final Action1<? super T> onNext) {
49674967
* {@link Action1} to execute when an error is emitted.
49684968
* @throws IllegalArgumentException
49694969
* if {@code onNext} is null, or
4970-
* if {@code onError} is null, or
4971-
* if {@code onComplete} is null
4970+
* if {@code onError} is null
4971+
* @throws OnErrorNotImplementedException
4972+
* if the Observable calls {@code onError}
49724973
* @see <a href="http://reactivex.io/documentation/operators/subscribe.html">ReactiveX operators documentation: Subscribe</a>
49734974
*/
49744975
public final void forEach(final Action1<? super T> onNext, final Action1<Throwable> onError) {
@@ -4994,6 +4995,8 @@ public final void forEach(final Action1<? super T> onNext, final Action1<Throwab
49944995
* if {@code onNext} is null, or
49954996
* if {@code onError} is null, or
49964997
* if {@code onComplete} is null
4998+
* @throws OnErrorNotImplementedException
4999+
* if the Observable calls {@code onError}
49975000
* @see <a href="http://reactivex.io/documentation/operators/subscribe.html">ReactiveX operators documentation: Subscribe</a>
49985001
*/
49995002
public final void forEach(final Action1<? super T> onNext, final Action1<Throwable> onError, final Action0 onComplete) {
@@ -7520,7 +7523,7 @@ public final void onNext(T args) {
75207523
* @throws IllegalArgumentException
75217524
* if {@code onNext} is null
75227525
* @throws OnErrorNotImplementedException
7523-
* if the Observable tries to call {@code onError}
7526+
* if the Observable calls {@code onError}
75247527
* @see <a href="http://reactivex.io/documentation/operators/subscribe.html">ReactiveX operators documentation: Subscribe</a>
75257528
*/
75267529
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)