25
25
import rx .Observable ;
26
26
import rx .Observer ;
27
27
import rx .functions .Action1 ;
28
+ import rx .functions .Func1 ;
29
+ import rx .observables .GroupedObservable ;
28
30
import rx .subjects .PublishSubject ;
29
31
30
32
public class ExceptionsTest {
@@ -45,7 +47,7 @@ public void call(Integer t1) {
45
47
public void testStackOverflowWouldOccur () {
46
48
final PublishSubject <Integer > a = PublishSubject .create ();
47
49
final PublishSubject <Integer > b = PublishSubject .create ();
48
- final int MAX_STACK_DEPTH = 1000 ;
50
+ final int MAX_STACK_DEPTH = 800 ;
49
51
final AtomicInteger depth = new AtomicInteger ();
50
52
51
53
a .subscribe (new Observer <Integer >() {
@@ -156,10 +158,72 @@ public void onNext(Object o) {
156
158
}
157
159
});
158
160
fail ("expecting an exception to be thrown" );
159
- } catch (CompositeException t ) {
160
- assertTrue (t .getExceptions ().get (0 ) instanceof IllegalArgumentException );
161
- assertTrue (t .getExceptions ().get (1 ) instanceof IllegalStateException );
161
+ } catch (OnErrorFailedException t ) {
162
+ CompositeException cause = (CompositeException ) t .getCause ();
163
+ assertTrue (cause .getExceptions ().get (0 ) instanceof IllegalArgumentException );
164
+ assertTrue (cause .getExceptions ().get (1 ) instanceof IllegalStateException );
162
165
}
163
166
}
164
167
168
+ /**
169
+ * https://github.com/ReactiveX/RxJava/issues/2998
170
+ */
171
+ @ Test (expected = OnErrorFailedException .class )
172
+ public void testOnErrorExceptionIsThrownFromGroupBy () throws Exception {
173
+ Observable
174
+ .just (1 )
175
+ .groupBy (new Func1 <Integer , Integer >() {
176
+ @ Override
177
+ public Integer call (Integer integer ) {
178
+ throw new RuntimeException ();
179
+ }
180
+ })
181
+ .subscribe (new Observer <GroupedObservable <Integer , Integer >>() {
182
+ @ Override
183
+ public void onCompleted () {
184
+
185
+ }
186
+
187
+ @ Override
188
+ public void onError (Throwable e ) {
189
+ throw new RuntimeException ();
190
+ }
191
+
192
+ @ Override
193
+ public void onNext (GroupedObservable <Integer , Integer > integerIntegerGroupedObservable ) {
194
+
195
+ }
196
+ });
197
+ }
198
+
199
+ /**
200
+ * https://github.com/ReactiveX/RxJava/issues/2998
201
+ */
202
+ @ Test (expected = OnErrorFailedException .class )
203
+ public void testOnErrorExceptionIsThrownFromOnNext () throws Exception {
204
+ Observable
205
+ .just (1 )
206
+ .doOnNext (new Action1 <Integer >() {
207
+ @ Override
208
+ public void call (Integer integer ) {
209
+ throw new RuntimeException ();
210
+ }
211
+ })
212
+ .subscribe (new Observer <Integer >() {
213
+ @ Override
214
+ public void onCompleted () {
215
+
216
+ }
217
+
218
+ @ Override
219
+ public void onError (Throwable e ) {
220
+ throw new RuntimeException ();
221
+ }
222
+
223
+ @ Override
224
+ public void onNext (Integer integer ) {
225
+
226
+ }
227
+ });
228
+ }
165
229
}
0 commit comments