Skip to content

Commit a97d871

Browse files
authored
3.x: Add missing throwIfFatal calls (#6801)
1 parent d1cbf57 commit a97d871

22 files changed

+144
-11
lines changed

src/main/java/io/reactivex/rxjava3/disposables/AutoCloseableDisposable.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
package io.reactivex.rxjava3.disposables;
1515

1616
import io.reactivex.rxjava3.annotations.NonNull;
17-
import io.reactivex.rxjava3.plugins.RxJavaPlugins;
17+
import io.reactivex.rxjava3.internal.util.ExceptionHelper;
1818

1919
/**
2020
* A disposable container that manages an {@link AutoCloseable} instance.
@@ -33,7 +33,7 @@ protected void onDisposed(@NonNull AutoCloseable value) {
3333
try {
3434
value.close();
3535
} catch (Throwable ex) {
36-
RxJavaPlugins.onError(ex);
36+
throw ExceptionHelper.wrapOrThrow(ex);
3737
}
3838
}
3939

src/main/java/io/reactivex/rxjava3/internal/jdk8/FlowableFlatMapStream.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import io.reactivex.rxjava3.annotations.NonNull;
2323
import io.reactivex.rxjava3.core.*;
24-
import io.reactivex.rxjava3.exceptions.MissingBackpressureException;
24+
import io.reactivex.rxjava3.exceptions.*;
2525
import io.reactivex.rxjava3.functions.*;
2626
import io.reactivex.rxjava3.internal.fuseable.*;
2727
import io.reactivex.rxjava3.internal.queue.SpscArrayQueue;
@@ -61,6 +61,7 @@ protected void subscribeActual(Subscriber<? super R> s) {
6161
stream = Objects.requireNonNull(mapper.apply(t), "The mapper returned a null Stream");
6262
}
6363
} catch (Throwable ex) {
64+
Exceptions.throwIfFatal(ex);
6465
EmptySubscription.error(ex, s);
6566
return;
6667
}
@@ -243,6 +244,7 @@ void drain() {
243244
try {
244245
t = queue.poll();
245246
} catch (Throwable ex) {
247+
Exceptions.throwIfFatal(ex);
246248
trySignalError(downstream, ex);
247249
continue;
248250
}
@@ -271,6 +273,7 @@ else if (!isEmpty) {
271273
iterator = null;
272274
}
273275
} catch (Throwable ex) {
276+
Exceptions.throwIfFatal(ex);
274277
trySignalError(downstream, ex);
275278
}
276279
continue;
@@ -282,6 +285,7 @@ else if (!isEmpty) {
282285
try {
283286
item = Objects.requireNonNull(iterator.next(), "The Stream.Iterator returned a null value");
284287
} catch (Throwable ex) {
288+
Exceptions.throwIfFatal(ex);
285289
trySignalError(downstream, ex);
286290
continue;
287291
}
@@ -297,6 +301,7 @@ else if (!isEmpty) {
297301
clearCurrentRethrowCloseError();
298302
}
299303
} catch (Throwable ex) {
304+
Exceptions.throwIfFatal(ex);
300305
trySignalError(downstream, ex);
301306
}
302307
}
@@ -328,6 +333,7 @@ void clearCurrentSuppressCloseError() {
328333
try {
329334
clearCurrentRethrowCloseError();
330335
} catch (Throwable ex) {
336+
Exceptions.throwIfFatal(ex);
331337
RxJavaPlugins.onError(ex);
332338
}
333339
}

src/main/java/io/reactivex/rxjava3/internal/jdk8/ObservableFlatMapStream.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ protected void subscribeActual(Observer<? super R> observer) {
5555
stream = Objects.requireNonNull(mapper.apply(t), "The mapper returned a null Stream");
5656
}
5757
} catch (Throwable ex) {
58+
Exceptions.throwIfFatal(ex);
5859
EmptyDisposable.error(ex, observer);
5960
return;
6061
}

src/main/java/io/reactivex/rxjava3/internal/operators/flowable/FlowableCollect.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ protected void subscribeActual(Subscriber<? super U> s) {
3939
try {
4040
u = Objects.requireNonNull(initialSupplier.get(), "The initial value supplied is null");
4141
} catch (Throwable e) {
42+
Exceptions.throwIfFatal(e);
4243
EmptySubscription.error(e, s);
4344
return;
4445
}

src/main/java/io/reactivex/rxjava3/internal/operators/flowable/FlowableCollectSingle.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ protected void subscribeActual(SingleObserver<? super U> observer) {
4444
try {
4545
u = Objects.requireNonNull(initialSupplier.get(), "The initialSupplier returned a null value");
4646
} catch (Throwable e) {
47+
Exceptions.throwIfFatal(e);
4748
EmptyDisposable.error(e, observer);
4849
return;
4950
}

src/main/java/io/reactivex/rxjava3/internal/operators/flowable/FlowableDoOnEach.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ public T poll() throws Throwable {
159159
try {
160160
onError.accept(ex);
161161
} catch (Throwable exc) {
162+
Exceptions.throwIfFatal(exc);
162163
throw new CompositeException(ex, exc);
163164
}
164165
throw ExceptionHelper.<Exception>throwIfThrowable(ex);
@@ -173,6 +174,7 @@ public T poll() throws Throwable {
173174
try {
174175
onError.accept(ex);
175176
} catch (Throwable exc) {
177+
Exceptions.throwIfFatal(exc);
176178
throw new CompositeException(ex, exc);
177179
}
178180
throw ExceptionHelper.<Exception>throwIfThrowable(ex);
@@ -314,6 +316,7 @@ public T poll() throws Throwable {
314316
try {
315317
onError.accept(ex);
316318
} catch (Throwable exc) {
319+
Exceptions.throwIfFatal(exc);
317320
throw new CompositeException(ex, exc);
318321
}
319322
throw ExceptionHelper.<Exception>throwIfThrowable(ex);
@@ -328,6 +331,7 @@ public T poll() throws Throwable {
328331
try {
329332
onError.accept(ex);
330333
} catch (Throwable exc) {
334+
Exceptions.throwIfFatal(exc);
331335
throw new CompositeException(ex, exc);
332336
}
333337
throw ExceptionHelper.<Exception>throwIfThrowable(ex);

src/main/java/io/reactivex/rxjava3/internal/operators/flowable/FlowableReplay.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ public void connect(Consumer<? super Disposable> connection) {
209209
try {
210210
connection.accept(ps);
211211
} catch (Throwable ex) {
212+
Exceptions.throwIfFatal(ex);
212213
if (doConnect) {
213214
ps.shouldConnect.compareAndSet(true, false);
214215
}

src/main/java/io/reactivex/rxjava3/internal/operators/flowable/FlowableScalarXMap.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ public void subscribeActual(Subscriber<? super R> s) {
136136
try {
137137
other = Objects.requireNonNull(mapper.apply(value), "The mapper returned a null Publisher");
138138
} catch (Throwable e) {
139+
Exceptions.throwIfFatal(e);
139140
EmptySubscription.error(e, s);
140141
return;
141142
}

src/main/java/io/reactivex/rxjava3/internal/operators/flowable/FlowableWindowBoundarySelector.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ void drain() {
245245
try {
246246
endSource = Objects.requireNonNull(closingIndicator.apply(startItem), "The closingIndicator returned a null Publisher");
247247
} catch (Throwable ex) {
248+
Exceptions.throwIfFatal(ex);
248249
upstream.cancel();
249250
startSubscriber.cancel();
250251
resources.dispose();

src/main/java/io/reactivex/rxjava3/internal/operators/flowable/FlowableZipIterable.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,15 @@ public void onNext(T t) {
101101
try {
102102
u = Objects.requireNonNull(iterator.next(), "The iterator returned a null value");
103103
} catch (Throwable e) {
104-
error(e);
104+
fail(e);
105105
return;
106106
}
107107

108108
V v;
109109
try {
110110
v = Objects.requireNonNull(zipper.apply(t, u), "The zipper function returned a null value");
111111
} catch (Throwable e) {
112-
error(e);
112+
fail(e);
113113
return;
114114
}
115115

@@ -120,7 +120,7 @@ public void onNext(T t) {
120120
try {
121121
b = iterator.hasNext();
122122
} catch (Throwable e) {
123-
error(e);
123+
fail(e);
124124
return;
125125
}
126126

@@ -131,7 +131,7 @@ public void onNext(T t) {
131131
}
132132
}
133133

134-
void error(Throwable e) {
134+
void fail(Throwable e) {
135135
Exceptions.throwIfFatal(e);
136136
done = true;
137137
upstream.cancel();

0 commit comments

Comments
 (0)