Description
ApiManager.getApi().dispatchService(SPUtils.getUserId(), groupType)
.observeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new ResultSubscriber() {
@OverRide
public void onSuccess(ServiceResultBean serviceResultBean) {
}
@Override
public void onError(ResultException error) {
name.setText(error.getMessage());
}
@Override
public void onCompleted() {
loading.setVisibility(View.GONE);
}
});
then...
E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.IllegalStateException: Fatal Exception thrown on Scheduler.Worker thread.
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:62)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: rx.exceptions.OnErrorFailedException: Error occurred when trying to propagate error to Observer.onError
at rx.observers.SafeSubscriber._onError(SafeSubscriber.java:201)
at rx.observers.SafeSubscriber.onError(SafeSubscriber.java:111)
at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.pollQueue(OperatorObserveOn.java:197)
at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber$2.call(OperatorObserveOn.java:170)
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: rx.exceptions.CompositeException: 2 exceptions occurred.
at rx.observers.SafeSubscriber._onError(SafeSubscriber.java:201)
at rx.observers.SafeSubscriber.onError(SafeSubscriber.java:111)
at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.pollQueue(OperatorObserveOn.java:197)
at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber$2.call(OperatorObserveOn.java:170)
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: rx.exceptions.CompositeException$CompositeExceptionCausalChain: Chain of Causes for CompositeException In Order Received =>
at android.util.Log.getStackTraceString(Log.java:314)
at android.util.Slog.e(Slog.java:77)
at com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:72)
at u.aly.n.uncaughtException(CrashHandler.java:34)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:693)
at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:690)
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:66)
at android.os.Handler.handleCallback(Handler.java:615)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4745)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
at dalvik.system.NativeStart.main(Native Method)
Caused by: retrofit.RetrofitError
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:395)
at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
at retrofit.RestAdapter$RestHandler$1.invoke(RestAdapter.java:265)
at retrofit.RxSupport$2.run(RxSupport.java:55)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
at java.util.concurrent.FutureTask.run(FutureTask.java:137)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
at retrofit.Platform$Android$2$1.run(Platform.java:142)
at java.lang.Thread.run(Thread.java:856)
Caused by: java.net.SocketTimeoutException
at java.net.PlainSocketImpl.read(PlainSocketImpl.java:491)
at java.net.PlainSocketImpl.access$000(PlainSocketImpl.java:46)
at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:240)
at okio.Okio$2.read(Okio.java:137)
at okio.AsyncTimeout$2.read(AsyncTimeout.java:211)
at okio.RealBufferedSource.indexOf(RealBufferedSource.java:306)
at okio.RealBufferedSource.indexOf(RealBufferedSource.java:300)
at okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:196)
at com.squareup.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:191)
at com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:80)
at com.squareup.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:917)
at com.squareup.okhttp.internal.http.HttpEngine.access$300(HttpEngine.java:95)
at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:902)
at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:760)
at com.squareup.okhttp.Call.getResponse(Call.java:274)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:230)
at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:201)
at com.squareup.okhttp.Call.execute(Call.java:81)
at retrofit.client.OkClient.exec
Activity
cuimingqiang commentedon Sep 17, 2015
please fix!!!
cuimingqiang commentedon Sep 17, 2015
RestAdapter.Builder()
.setErrorHandler(new ErrorHandler() {
@OverRide
public Throwable handleError(RetrofitError cause) {
return new Throwable(cause.getCause());
}
})
It can fix that,
qbraet commentedon Sep 18, 2015
I seem to have the same issue:
java.lang.IllegalStateException: Fatal Exception thrown on Scheduler.Worker thread.
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:62)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
Caused by: d.b.h: Error occurred when trying to propagate error to Observer.onError
at rx.observers.SafeSubscriber._onError(SafeSubscriber.java:201)
at rx.observers.SafeSubscriber.onError(SafeSubscriber.java:111)
at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber$2.rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.pollQueue(OperatorObserveOn.java:1197)
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
Caused by: d.b.a: 2 exceptions occurred.
at rx.observers.SafeSubscriber._onError(SafeSubscriber.java:201)
at rx.observers.SafeSubscriber.onError(SafeSubscriber.java:111)
at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber$2.rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.pollQueue(OperatorObserveOn.java:1197)
at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
at java.lang.reflect.Method.invoke(Method.java)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:905)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:700)
Caused by: d.b.b: Chain of Causes for CompositeException In Order Received =>
at com.crashlytics.android.CrashlyticsUncaughtExceptionHandler.getEventAppExecutionExceptionSize(CrashlyticsUncaughtExceptionHandler.java:1962)
at com.crashlytics.android.CrashlyticsUncaughtExceptionHandler.getEventAppExecutionExceptionSize(CrashlyticsUncaughtExceptionHandler.java:1965)
at com.crashlytics.android.CrashlyticsUncaughtExceptionHandler.getEventAppExecutionExceptionSize(CrashlyticsUncaughtExceptionHandler.java:1965)
at com.crashlytics.android.CrashlyticsUncaughtExceptionHandler.getEventAppExecutionSize(CrashlyticsUncaughtExceptionHandler.java:1901)
at com.crashlytics.android.CrashlyticsUncaughtExceptionHandler.getEventAppSize(CrashlyticsUncaughtExceptionHandler.java:1861)
at com.crashlytics.android.CrashlyticsUncaughtExceptionHandler.getSessionEventSize(CrashlyticsUncaughtExceptionHandler.java:20841)
at com.crashlytics.android.CrashlyticsUncaughtExceptionHandler.writeFatal(CrashlyticsUncaughtExceptionHandler.java:26444)
at com.crashlytics.android.CrashlyticsUncaughtExceptionHandler$7.call(CrashlyticsUncaughtExceptionHandler.java:1324)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at io.fabric.sdk.android.services.common.ExecutorUtils$1$1.onRun(ExecutorUtils.java:46)
at io.fabric.sdk.android.services.common.BackgroundPriorityRunnable.run(BackgroundPriorityRunnable.java:13)
at java.lang.Thread.run(Thread.java:818)
Caused by: retrofit.RetrofitError: Unable to resolve host "www.example.com": No address associated with hostname
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:395)
at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
at retrofit.RestAdapter$RestHandler$1.invoke(RestAdapter.java:265)
at retrofit.RxSupport$2.run(RxSupport.java:55)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at retrofit.Platform$Android$2$1.run(Platform.java:142)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.net.UnknownHostException: Unable to resolve host "www.example.com": No address associated with hostname
at java.net.InetAddress.lookupHostByName(InetAddress.java:427)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
at java.net.InetAddress.getAllByName(InetAddress.java:215)
at com.squareup.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29)
at com.squareup.okhttp.internal.http.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:224)
at com.squareup.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:193)
at com.squareup.okhttp.internal.http.RouteSelector.next(RouteSelector.java:113)
at com.squareup.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:344)
at com.squareup.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:329)
at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:319)
at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:241)
at com.squareup.okhttp.Call.getResponse(Call.java:271)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:228)
at com.example.TokenExpiredInterceptor.intercept(TokenExpiredInterceptor.java:46)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:225)
at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:199)
at com.squareup.okhttp.Call.execute(Call.java:79)
at retrofit.client.OkClient.execute(OkClient.java:53)
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:326)
at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
at retrofit.RestAdapter$RestHandler$1.invoke(RestAdapter.java:265)
at retrofit.RxSupport$2.run(RxSupport.java:55)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at retrofit.Platform$Android$2$1.run(Platform.java:142)
at java.lang.Thread.run(Thread.java:818)
The only difference is that I have an okhttp interceptor to check auth tokens, but the crash happens before it executes some of my logic
...
}
cuimingqiang commentedon Sep 19, 2015
you can try
RestAdapter.Builder()
.setErrorHandler(new ErrorHandler() {
@OverRide
public Throwable handleError(RetrofitError cause) {
return cause.getCause();
}
})
I solved through that.
please check!
cuimingqiang commentedon Sep 19, 2015
Problem is the same as below:
try {
Observable.create(new Observable.OnSubscribe() {
public void call(Subscriber<? super String> subscriber) {
subscriber.onError(new Throwable("---"));
subscriber.onNext("create----");
subscriber.onCompleted();
so, Due to throw OnErrorFailedException in onError.
IgorGanapolsky commentedon Sep 25, 2015
Is there any resolution for this? I am getting the same error.
cuimingqiang commentedon Sep 26, 2015
RestAdapter.Builder()
.setErrorHandler(new ErrorHandler() {
@OverRide
public Throwable handleError(RetrofitError cause) {
return new Throwable(cause.getCause());
}
}),,can fix the question。
sureshs592 commentedon Oct 19, 2015
Hello folks! I'm facing this issue under very specific circumstances. Gets triggered when there's bad network connectivity and the request eventually times out. What's peculiar is I do have an
ErrorHandler
implementation set in theRestAdapter
object.More information about my current app setup:
1.9.0
and okhttp-urlconnection version2.5.0
. Was previously on version1.7.0
and2.1.0
. Do not remember seeing this crash on those versions.0.24.0
Have attached the stack trace with some notes below. I'm trying to reproduce this issue more reliably. Will update on this thread if I manage to do so. Please let me know if you need any other information. Looking forward to any help/inputs on this!
Stack trace
Would like to highlight two things in the stack trace here:
com.squareup.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29)
co.ninetynine.android.core.api.RetrofitErrorHandler.handleError(RetrofitErrorHandler.java:37)
cuimingqiang commentedon Oct 19, 2015
This problem is due to in the "onError (Throwable e)" in raise the exception again. please check your “ RetrofitErrorHandler” ,and look RxSupport
private Runnable getRunnable(final Subscriber<? super Object> subscriber, final Invoker invoker,
final RequestInterceptorTape interceptorTape) {
return new Runnable() {
@OverRide public void run() {
try {
if (subscriber.isUnsubscribed()) {
return;
}
ResponseWrapper wrapper = invoker.invoke(interceptorTape);
subscriber.onNext(wrapper.responseBody);
subscriber.onCompleted();
} catch (RetrofitError e) {
subscriber.onError(errorHandler.handleError(e));
}
}
};
}
scana commentedon Oct 20, 2015
Hi @sureshs592, I'm facing almost identical issue, but I have no idea what @cuimingqiang actually wanted to say.
Did you manage to do anything with it? Maybe you could just open a new issue (containing all of that stuff that you've posted in your comment)?
sureshs592 commentedon Oct 21, 2015
Hey @cuimingqiang thanks for your prompt response! Your point makes sense, and I suspected the same issue too. I wrapped the entire code in my Retrofit ErrorHandler inside a try-catch block to see if that was the case. I'm afraid that didn't fix the issue.
Hey @scana , @cuimingqiang explained that there might have been some line of code within my Retrofit ErrorHandler code which might have thrown an exception, causing the fatal crash that we notice (the method is only supposed to return exceptions). But my try-catch fix didn't help so I doubt that is the issue now.
Will open a new issue as you suggested. I'm suspecting the Retrofit library code might be throwing an exception at some particular location rather than sending it to the subscriber's
onError
method.erikjhordan-rey commentedon Oct 29, 2015
Hi everybody! Is there any resolution for this? I am getting the same error.
I´m using io.reactivex:rxandroid:1.0.1 , io.reactivex:rxjava:1.0.14 , com.squareup.retrofit:retrofit:2.0.0-beta1' .
liu-xinhui commentedon Nov 23, 2015
@cuimingqiang @sureshs592
I get the same error
this method do not work
RestAdapter.Builder()
.setErrorHandler(new ErrorHandler() {
@OverRide
public Throwable handleError(RetrofitError cause) {
return new Throwable(cause.getCause());
}
})
25 remaining items