|
4 | 4 | import org.junit.runner.Description; |
5 | 5 | import org.junit.runners.model.Statement; |
6 | 6 |
|
7 | | -import java.lang.reflect.InvocationTargetException; |
8 | | -import java.lang.reflect.Method; |
9 | | - |
10 | 7 | import rx.Scheduler; |
11 | 8 | import rx.android.plugins.RxAndroidPlugins; |
12 | 9 | import rx.android.plugins.RxAndroidSchedulersHook; |
@@ -41,30 +38,21 @@ public Scheduler getMainThreadScheduler() { |
41 | 38 | } |
42 | 39 | }; |
43 | 40 |
|
44 | | - // Hack to get around RxJavaPlugins.reset() not being public |
45 | | - // See https://github.com/ReactiveX/RxJava/issues/2297 |
46 | | - // Hopefully the method will be public in new releases of RxAndroid and we can remove the hack. |
47 | | - private void callResetViaReflectionIn(RxJavaPlugins rxJavaPlugins) |
48 | | - throws InvocationTargetException, IllegalAccessException, NoSuchMethodException { |
49 | | - Method method = rxJavaPlugins.getClass().getDeclaredMethod("reset"); |
50 | | - method.setAccessible(true); |
51 | | - method.invoke(rxJavaPlugins); |
52 | | - } |
53 | | - |
54 | 41 | @Override |
55 | 42 | public Statement apply(final Statement base, Description description) { |
56 | 43 | return new Statement() { |
57 | 44 | @Override |
58 | 45 | public void evaluate() throws Throwable { |
59 | 46 | RxAndroidPlugins.getInstance().reset(); |
60 | 47 | RxAndroidPlugins.getInstance().registerSchedulersHook(mRxAndroidSchedulersHook); |
61 | | - callResetViaReflectionIn(RxJavaPlugins.getInstance()); |
| 48 | + |
| 49 | + RxJavaPlugins.getInstance().reset(); |
62 | 50 | RxJavaPlugins.getInstance().registerSchedulersHook(mRxJavaSchedulersHook); |
63 | 51 |
|
64 | 52 | base.evaluate(); |
65 | 53 |
|
66 | 54 | RxAndroidPlugins.getInstance().reset(); |
67 | | - callResetViaReflectionIn(RxJavaPlugins.getInstance()); |
| 55 | + RxJavaPlugins.getInstance().reset(); |
68 | 56 | } |
69 | 57 | }; |
70 | 58 | } |
|
0 commit comments