Skip to content

Commit 4b612f6

Browse files
committed
Add QueueOverflowException, fix tests
1 parent cc04ccf commit 4b612f6

34 files changed

+103
-71
lines changed

src/main/java/io/reactivex/rxjava3/exceptions/MissingBackpressureException.java

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,6 @@ public final class MissingBackpressureException extends RuntimeException {
2929
*/
3030
public static final String DEFAULT_MESSAGE = "Could not emit value due to lack of requests";
3131

32-
/**
33-
* The message for queue overflows.
34-
* <p>
35-
* This can happen if the upstream disregards backpressure completely or calls
36-
* {@link org.reactivestreams.Subscriber#onNext(Object)} concurrently from multiple threads
37-
* without synchronization. Rarely, it is an indication of bugs inside RxJava
38-
* @since 3.1.6
39-
*/
40-
public static final String QUEUE_OVERFLOW_MESSAGE = "Queue overflow due to illegal concurrent onNext calls or a bug in RxJava";
41-
4232
/**
4333
* Constructs a MissingBackpressureException without message or cause.
4434
*/
@@ -63,14 +53,4 @@ public MissingBackpressureException(String message) {
6353
public static MissingBackpressureException createDefault() {
6454
return new MissingBackpressureException(DEFAULT_MESSAGE);
6555
}
66-
67-
/**
68-
* Constructs a new {@code MissingBackpressureException} with the
69-
* default message {@value #QUEUE_OVERFLOW_MESSAGE}.
70-
* @return the new {@code MissingBackpressureException} instance.
71-
* @since 3.1.6
72-
*/
73-
public static MissingBackpressureException createQueueOverflow() {
74-
return new MissingBackpressureException(QUEUE_OVERFLOW_MESSAGE);
75-
}
7656
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright (c) 2016-present, RxJava Contributors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in
5+
* compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License is
10+
* distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See
11+
* the License for the specific language governing permissions and limitations under the License.
12+
*/
13+
14+
package io.reactivex.rxjava3.exceptions;
15+
16+
/**
17+
* Indicates an overflow happened because the upstream disregarded backpressure completely or
18+
* {@link org.reactivestreams.Subscriber#onNext(Object)} was called concurrently from multiple threads
19+
* without synchronization. Rarely, it is an indication of bugs inside an operator.
20+
* @since 3.1.6
21+
*/
22+
public final class QueueOverflowException extends RuntimeException {
23+
24+
private static final long serialVersionUID = 8517344746016032542L;
25+
26+
/**
27+
* The message for queue overflows.
28+
* <p>
29+
* This can happen if the upstream disregards backpressure completely or calls
30+
* {@link org.reactivestreams.Subscriber#onNext(Object)} concurrently from multiple threads
31+
* without synchronization. Rarely, it is an indication of bugs inside an operator.
32+
*/
33+
private static final String DEFAULT_MESSAGE = "Queue overflow due to illegal concurrent onNext calls or a bug in an operator";
34+
35+
/**
36+
* Constructs a QueueOverflowException with the default message.
37+
*/
38+
public QueueOverflowException() {
39+
this(DEFAULT_MESSAGE);
40+
}
41+
42+
/**
43+
* Constructs a QueueOverflowException with the given message but no cause.
44+
* @param message the error message
45+
*/
46+
public QueueOverflowException(String message) {
47+
super(message);
48+
}
49+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ public void onNext(T t) {
174174
if (sourceMode != QueueFuseable.ASYNC) {
175175
if (!queue.offer(t)) {
176176
upstream.cancel();
177-
onError(MissingBackpressureException.createQueueOverflow());
177+
onError(new QueueOverflowException());
178178
return;
179179
}
180180
}

src/main/java/io/reactivex/rxjava3/internal/operators/completable/CompletableConcat.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ public void onSubscribe(Subscription s) {
120120
public void onNext(CompletableSource t) {
121121
if (sourceFused == QueueSubscription.NONE) {
122122
if (!queue.offer(t)) {
123-
onError(MissingBackpressureException.createQueueOverflow());
123+
onError(new QueueOverflowException());
124124
return;
125125
}
126126
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public void onNext(T t) {
140140
if (!queue.offer(t)) {
141141
SubscriptionHelper.cancel(this);
142142

143-
onError(MissingBackpressureException.createQueueOverflow());
143+
onError(new QueueOverflowException());
144144
} else {
145145
signalConsumer();
146146
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public final void onNext(T t) {
152152
if (sourceMode != QueueSubscription.ASYNC) {
153153
if (!queue.offer(t)) {
154154
upstream.cancel();
155-
onError(MissingBackpressureException.createQueueOverflow());
155+
onError(new QueueOverflowException());
156156
return;
157157
}
158158
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public final void onNext(T t) {
151151
if (sourceMode != QueueSubscription.ASYNC) {
152152
if (!queue.offer(t)) {
153153
upstream.cancel();
154-
onError(MissingBackpressureException.createQueueOverflow());
154+
onError(new QueueOverflowException());
155155
return;
156156
}
157157
}

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ void tryEmitScalar(U value) {
243243
q = getMainQueue();
244244
}
245245
if (!q.offer(value)) {
246-
onError(MissingBackpressureException.createQueueOverflow());
246+
onError(new QueueOverflowException());
247247
}
248248
}
249249
if (decrementAndGet() == 0) {
@@ -252,7 +252,7 @@ void tryEmitScalar(U value) {
252252
} else {
253253
SimpleQueue<U> q = getMainQueue();
254254
if (!q.offer(value)) {
255-
onError(MissingBackpressureException.createQueueOverflow());
255+
onError(new QueueOverflowException());
256256
return;
257257
}
258258
if (getAndIncrement() != 0) {
@@ -278,7 +278,7 @@ void tryEmit(U value, InnerSubscriber<T, U> inner) {
278278
inner.queue = q;
279279
}
280280
if (!q.offer(value)) {
281-
onError(MissingBackpressureException.createQueueOverflow());
281+
onError(new QueueOverflowException());
282282
}
283283
}
284284
if (decrementAndGet() == 0) {
@@ -291,7 +291,7 @@ void tryEmit(U value, InnerSubscriber<T, U> inner) {
291291
inner.queue = q;
292292
}
293293
if (!q.offer(value)) {
294-
onError(MissingBackpressureException.createQueueOverflow());
294+
onError(new QueueOverflowException());
295295
return;
296296
}
297297
if (getAndIncrement() != 0) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public void onNext(T t) {
180180
return;
181181
}
182182
if (fusionMode == NONE && !queue.offer(t)) {
183-
onError(MissingBackpressureException.createQueueOverflow());
183+
onError(new QueueOverflowException());
184184
return;
185185
}
186186
drain();

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public final void onNext(T t) {
113113
if (!queue.offer(t)) {
114114
upstream.cancel();
115115

116-
error = MissingBackpressureException.createQueueOverflow();
116+
error = new QueueOverflowException();
117117
done = true;
118118
}
119119
trySchedule();

0 commit comments

Comments
 (0)