Skip to content

Commit c649922

Browse files
vanniktechakarnokd
authored andcommitted
2.x: Remove unused exceptions in public API (ReactiveX#4309)
1 parent f7d7809 commit c649922

File tree

10 files changed

+91
-201
lines changed

10 files changed

+91
-201
lines changed

src/main/java/io/reactivex/exceptions/Exceptions.java

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ public static RuntimeException propagate(Throwable t) {
5252
* Throws a particular {@code Throwable} only if it belongs to a set of "fatal" error varieties. These
5353
* varieties are as follows:
5454
* <ul>
55-
* <li>{@link OnErrorNotImplementedException}</li>
56-
* <li>{@link OnErrorFailedException}</li>
57-
* <li>{@link OnCompleteFailedException}</li>
5855
* <li>{@code StackOverflowError}</li>
5956
* <li>{@code VirtualMachineError}</li>
6057
* <li>{@code ThreadDeath}</li>
@@ -70,15 +67,8 @@ public static RuntimeException propagate(Throwable t) {
7067
* @see <a href="https://github.com/ReactiveX/RxJava/issues/748#issuecomment-32471495">RxJava: StackOverflowError is swallowed (Issue #748)</a>
7168
*/
7269
public static void throwIfFatal(Throwable t) {
73-
if (t instanceof OnErrorNotImplementedException) {
74-
throw (OnErrorNotImplementedException) t;
75-
} else if (t instanceof OnErrorFailedException) {
76-
throw (OnErrorFailedException) t;
77-
} else if (t instanceof OnCompleteFailedException) {
78-
throw (OnCompleteFailedException) t;
79-
}
8070
// values here derived from https://github.com/ReactiveX/RxJava/issues/748#issuecomment-32471495
81-
else if (t instanceof StackOverflowError) {
71+
if (t instanceof StackOverflowError) {
8272
throw (StackOverflowError) t;
8373
} else if (t instanceof VirtualMachineError) {
8474
throw (VirtualMachineError) t;

src/main/java/io/reactivex/exceptions/OnCompleteFailedException.java

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/main/java/io/reactivex/exceptions/OnErrorFailedException.java

Lines changed: 0 additions & 27 deletions
This file was deleted.

src/main/java/io/reactivex/exceptions/OnErrorNotImplementedException.java

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/main/java/io/reactivex/exceptions/UnsubscribeFailedException.java

Lines changed: 0 additions & 24 deletions
This file was deleted.

src/test/java/io/reactivex/exceptions/ExceptionsNullTest.java

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,39 +22,44 @@
2222
*/
2323
public class ExceptionsNullTest {
2424

25+
@Ignore("OnCompleteFailedException will likely not be ported")
2526
@Test
2627
public void testOnCompleteFailedExceptionNull() {
27-
Throwable t = new OnCompleteFailedException(null);
28-
29-
Assert.assertTrue(t.getCause() instanceof NullPointerException);
28+
// Throwable t = new OnCompleteFailedException(null);
29+
//
30+
// Assert.assertTrue(t.getCause() instanceof NullPointerException);
3031
}
31-
32+
33+
@Ignore("OnCompleteFailedException will likely not be ported")
3234
@Test
3335
public void testOnCompleteFailedExceptionMessageAndNull() {
34-
Throwable t = new OnCompleteFailedException("Message", null);
35-
36-
Assert.assertTrue(t.getCause() instanceof NullPointerException);
36+
// Throwable t = new OnCompleteFailedException("Message", null);
37+
//
38+
// Assert.assertTrue(t.getCause() instanceof NullPointerException);
3739
}
3840

41+
@Ignore("OnErrorFailedException will likely not be ported")
3942
@Test
4043
public void testOnErrorFailedExceptionNull() {
41-
Throwable t = new OnErrorFailedException(null);
42-
43-
Assert.assertTrue(t.getCause() instanceof NullPointerException);
44+
// Throwable t = new OnErrorFailedException(null);
45+
//
46+
// Assert.assertTrue(t.getCause() instanceof NullPointerException);
4447
}
45-
48+
49+
@Ignore("OnErrorFailedException will likely not be ported")
4650
@Test
4751
public void testOnErrorFailedExceptionMessageAndNull() {
48-
Throwable t = new OnErrorFailedException("Message", null);
49-
50-
Assert.assertTrue(t.getCause() instanceof NullPointerException);
52+
// Throwable t = new OnErrorFailedException("Message", null);
53+
//
54+
// Assert.assertTrue(t.getCause() instanceof NullPointerException);
5155
}
52-
56+
57+
@Ignore("UnsubscribeFailedException will likely not be ported")
5358
@Test
5459
public void testUnsubscribeFailedExceptionNull() {
55-
Throwable t = new UnsubscribeFailedException(null);
56-
57-
Assert.assertTrue(t.getCause() instanceof NullPointerException);
60+
// Throwable t = new UnsubscribeFailedException(null);
61+
//
62+
// Assert.assertTrue(t.getCause() instanceof NullPointerException);
5863
}
5964

6065
@Ignore("UnsubscribeFailedException will likely not be ported")
@@ -65,18 +70,20 @@ public void testUnsubscribeFailedExceptionMessageAndNull() {
6570
// Assert.assertTrue(t.getCause() instanceof NullPointerException);
6671
}
6772

73+
@Ignore("OnErrorNotImplementedException will likely not be ported")
6874
@Test
6975
public void testOnErrorNotImplementedExceptionNull() {
70-
Throwable t = new OnErrorNotImplementedException(null);
71-
72-
Assert.assertTrue(t.getCause() instanceof NullPointerException);
76+
// Throwable t = new OnErrorNotImplementedException(null);
77+
//
78+
// Assert.assertTrue(t.getCause() instanceof NullPointerException);
7379
}
74-
80+
81+
@Ignore("OnErrorNotImplementedException will likely not be ported")
7582
@Test
7683
public void testOnErrorNotImplementedExceptionMessageAndNull() {
77-
Throwable t = new OnErrorNotImplementedException("Message", null);
78-
79-
Assert.assertTrue(t.getCause() instanceof NullPointerException);
84+
// Throwable t = new OnErrorNotImplementedException("Message", null);
85+
//
86+
// Assert.assertTrue(t.getCause() instanceof NullPointerException);
8087
}
8188

8289
@Ignore("OnErrorThrowable may be ported later")

src/test/java/io/reactivex/exceptions/ExceptionsTest.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public void accept(Integer t1) {
6060
* https://github.com/ReactiveX/RxJava/issues/3885
6161
*/
6262
@Ignore("v2 components should not throw")
63-
@Test(expected = OnCompleteFailedException.class)
63+
@Test(expected = RuntimeException.class)
6464
public void testOnCompletedExceptionIsThrown() {
6565
Observable.empty()
6666
.subscribe(new Observer<Object>() {
@@ -227,7 +227,7 @@ public void onNext(Object o) {
227227
}
228228
});
229229
fail("expecting an exception to be thrown");
230-
} catch (OnErrorFailedException t) {
230+
} catch (RuntimeException t) {
231231
CompositeException cause = (CompositeException) t.getCause();
232232
assertTrue(cause.getExceptions().get(0) instanceof IllegalArgumentException);
233233
assertTrue(cause.getExceptions().get(1) instanceof IllegalStateException);
@@ -239,7 +239,7 @@ public void onNext(Object o) {
239239
* @throws Exception on arbitrary errors
240240
*/
241241
@Ignore("v2 components should not throw")
242-
@Test(expected = OnErrorFailedException.class)
242+
@Test(expected = RuntimeException.class)
243243
public void testOnErrorExceptionIsThrownFromGroupBy() throws Exception {
244244
Observable
245245
.just(1)
@@ -278,7 +278,7 @@ public void onNext(GroupedObservable<Integer, Integer> integerIntegerGroupedObse
278278
* @throws Exception on arbitrary errors
279279
*/
280280
@Ignore("v2 components should not throw")
281-
@Test(expected = OnErrorFailedException.class)
281+
@Test(expected = RuntimeException.class)
282282
public void testOnErrorExceptionIsThrownFromOnNext() throws Exception {
283283
Observable
284284
.just(1)
@@ -313,7 +313,7 @@ public void onNext(Integer integer) {
313313
}
314314

315315
@Ignore("v2 components should not throw")
316-
@Test(expected = OnErrorFailedException.class)
316+
@Test(expected = RuntimeException.class)
317317
public void testOnErrorExceptionIsThrownFromSubscribe() {
318318
Observable.create(new ObservableSource<Integer>() {
319319
@Override
@@ -330,7 +330,7 @@ public void subscribe(Observer<? super Integer> s2) {
330330
}
331331

332332
@Ignore("v2 components should not throw")
333-
@Test(expected = OnErrorFailedException.class)
333+
@Test(expected = RuntimeException.class)
334334
public void testOnErrorExceptionIsThrownFromUnsafeSubscribe() {
335335
Observable.create(new ObservableSource<Integer>() {
336336
@Override
@@ -347,7 +347,7 @@ public void subscribe(Observer<? super Integer> s2) {
347347
}
348348

349349
@Ignore("v2 components should not throw")
350-
@Test(expected = OnErrorFailedException.class)
350+
@Test(expected = RuntimeException.class)
351351
public void testOnErrorExceptionIsThrownFromSingleDoOnSuccess() throws Exception {
352352
Single.just(1)
353353
.doOnSuccess(new Consumer<Integer>() {
@@ -360,7 +360,7 @@ public void accept(Integer integer) {
360360
}
361361

362362
@Ignore("v2 components should not throw")
363-
@Test(expected = OnErrorFailedException.class)
363+
@Test(expected = RuntimeException.class)
364364
public void testOnErrorExceptionIsThrownFromSingleSubscribe() {
365365
Single.create(new SingleSource<Integer>() {
366366
@Override
@@ -377,7 +377,7 @@ public void subscribe(SingleObserver<? super Integer> s2) {
377377
}
378378

379379
@Ignore("v2 components should not throw")
380-
@Test(expected = OnErrorFailedException.class)
380+
@Test(expected = RuntimeException.class)
381381
public void testOnErrorExceptionIsThrownFromSingleUnsafeSubscribe() {
382382
Single.create(new SingleSource<Integer>() {
383383
@Override

src/test/java/io/reactivex/subscribers/SafeObserverTest.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public void onErrorNotImplementedFailureSafe() {
111111
new SafeSubscriber<String>(OBSERVER_ONERROR_NOTIMPLEMENTED()).onError(new SafeObserverTestException("error!"));
112112
fail("expects exception to be thrown");
113113
} catch (Exception e) {
114-
assertTrue(e instanceof OnErrorNotImplementedException);
114+
// assertTrue(e instanceof OnErrorNotImplementedException);
115115
assertTrue(e.getCause() instanceof SafeObserverTestException);
116116
assertEquals("error!", e.getCause().getMessage());
117117
}
@@ -180,7 +180,7 @@ public void request(long n) {
180180

181181
// FIXME no longer assertable
182182
// assertTrue(o.isUnsubscribed());
183-
assertTrue(e instanceof UnsubscribeFailedException);
183+
// assertTrue(e instanceof UnsubscribeFailedException);
184184
assertTrue(e.getCause() instanceof SafeObserverTestException);
185185
assertEquals("failure from unsubscribe", e.getMessage());
186186
// expected since onError fails so SafeObserver can't help
@@ -220,7 +220,7 @@ public void request(long n) {
220220
assertEquals("failed", onError.get().getMessage());
221221

222222
// now assert the exception that was thrown
223-
OnErrorFailedException onErrorFailedException = (OnErrorFailedException) e;
223+
RuntimeException onErrorFailedException = (RuntimeException) e;
224224
assertTrue(onErrorFailedException.getCause() instanceof SafeObserverTestException);
225225
assertEquals("failure from unsubscribe", e.getMessage());
226226
}
@@ -435,7 +435,8 @@ public void onComplete() {
435435

436436
@Override
437437
public void onError(Throwable e) {
438-
throw new OnErrorNotImplementedException(e);
438+
throw new RuntimeException(e);
439+
// throw new OnErrorNotImplementedException(e);
439440
}
440441

441442
@Override
@@ -496,7 +497,7 @@ public void onComplete() {
496497
try {
497498
s.onComplete();
498499
Assert.fail();
499-
} catch (OnCompleteFailedException e) {
500+
} catch (RuntimeException e) {
500501
assertNull(error.get());
501502
}
502503
}
@@ -518,4 +519,4 @@ public void onComplete() {
518519

519520
assertSame(actual, s.actual());
520521
}
521-
}
522+
}

0 commit comments

Comments
 (0)