File tree 1 file changed +17
-3
lines changed
src/main/java/rx/internal/operators
1 file changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -71,6 +71,7 @@ private static final class ObserveOnSubscriber<T> extends Subscriber<T> {
71
71
72
72
private final RxRingBuffer queue = RxRingBuffer .getSpscInstance ();
73
73
private boolean completed = false ;
74
+ private boolean failure = false ;
74
75
75
76
private volatile long requested = 0 ;
76
77
@ SuppressWarnings ("rawtypes" )
@@ -137,7 +138,11 @@ public void onError(final Throwable e) {
137
138
if (isUnsubscribed () || completed ) {
138
139
return ;
139
140
}
141
+ // unsubscribe eagerly since time will pass before the scheduled onError results in an unsubscribe event
142
+ unsubscribe ();
140
143
completed = true ;
144
+ // mark failure so the polling thread will skip onNext still in the queue
145
+ failure = true ;
141
146
queue .onError (e );
142
147
schedule ();
143
148
}
@@ -166,9 +171,18 @@ private void pollQueue() {
166
171
REQUESTED .incrementAndGet (this );
167
172
break ;
168
173
} else {
169
- if (!on .accept (child , o )) {
170
- // non-terminal event so let's increment count
171
- emitted ++;
174
+ if (failure ) {
175
+ // completed so we will skip onNext if they exist and only emit terminal events
176
+ if (on .isError (o )) {
177
+ System .out .println ("Error: " + o );
178
+ // only emit error
179
+ on .accept (child , o );
180
+ }
181
+ } else {
182
+ if (!on .accept (child , o )) {
183
+ // non-terminal event so let's increment count
184
+ emitted ++;
185
+ }
172
186
}
173
187
}
174
188
} else {
You can’t perform that action at this time.
0 commit comments