Skip to content

RxJava Retrofit --Fatal Exception thrown on Scheduler.Worker thread. #1088

Closed
@cuimingqiang

Description

@cuimingqiang

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

cuimingqiang commented on Sep 17, 2015

@cuimingqiang
Author

please fix!!!

cuimingqiang

cuimingqiang commented on Sep 17, 2015

@cuimingqiang
Author

RestAdapter.Builder()
.setErrorHandler(new ErrorHandler() {
@OverRide
public Throwable handleError(RetrofitError cause) {
return new Throwable(cause.getCause());
}
})
It can fix that,

qbraet

qbraet commented on Sep 18, 2015

@qbraet

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

@Override
public Response intercept(Chain chain) throws IOException
{
    // execute original request
    Response response = chain.proceed(chain.request()); // <- This is line 46 where the crash happens

    // Unauthorised request
    if (response.code() == 403) 
    {
          // refresh access token
          ...
    }

   return response;

...
}

cuimingqiang

cuimingqiang commented on Sep 19, 2015

@cuimingqiang
Author

you can try
RestAdapter.Builder()
.setErrorHandler(new ErrorHandler() {
@OverRide
public Throwable handleError(RetrofitError cause) {
return cause.getCause();
}
})

I solved through that.
please check!

cuimingqiang

cuimingqiang commented on Sep 19, 2015

@cuimingqiang
Author

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();

            }
        }).subscribeOn(Schedulers.io())
                .observeOn(Schedulers.newThread())
                .subscribe(new Action1<String>() {
                    public void call(String s) {
                    }
                }, new Action1<Throwable>() {
                    public void call(Throwable throwable) {
                        //TODO:
                        throw new OnErrorFailedException(throwable);
                    }
                }, new Action0() {
                    public void call() {
                    }
                });
    } catch (Exception e) {
        e.printStackTrace();
    }
    try {
        Thread.sleep(2000);
    } catch (Exception e) {
        e.printStackTrace();
    }

so, Due to throw OnErrorFailedException in onError.

IgorGanapolsky

IgorGanapolsky commented on Sep 25, 2015

@IgorGanapolsky

Is there any resolution for this? I am getting the same error.

cuimingqiang

cuimingqiang commented on Sep 26, 2015

@cuimingqiang
Author

RestAdapter.Builder()
.setErrorHandler(new ErrorHandler() {
@OverRide
public Throwable handleError(RetrofitError cause) {
return new Throwable(cause.getCause());
}
}),,can fix the question。

sureshs592

sureshs592 commented on Oct 19, 2015

@sureshs592

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 the RestAdapter object.

More information about my current app setup:

  • Currently using retrofit version 1.9.0 and okhttp-urlconnection version 2.5.0. Was previously on version 1.7.0 and 2.1.0. Do not remember seeing this crash on those versions.
  • rxandroid version 0.24.0
  • Snippet of my RestAdapter initialisation:
restAdapter = new RestAdapter.Builder().setEndpoint(baseUrl)
          .setConverter(new GsonConverter(gson))
          .setLogLevel(RestAdapter.LogLevel.HEADERS)
          .setClient(new OkClient(okHttpClient))
          .setRequestInterceptor(new NNRequestInterceptor())
          .setErrorHandler(new RetrofitErrorHandler(mContext))
          .build();
  • Snippet of my ErrorHandler implementation:
public class RetrofitErrorHandler implements ErrorHandler {
  private Context ctx;

  ...

  @Override public Throwable handleError(RetrofitError cause) {
    try {

      ...

      return new NetworkRequestException(cause, errorDescription);
    } catch (Exception e) {
      Timber.e(e, "Error while handling Retrofit error");
      return e;
    }
  }
}

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:

  • Error seems to originate from this line: com.squareup.okhttp.internal.Network$1.resolveInetAddresses(Network.java:29)
  • Also seems to pass through my error handler: co.ninetynine.android.core.api.RetrofitErrorHandler.handleError(RetrofitErrorHandler.java:37)
java.lang.IllegalStateException: Fatal Exception thrown on Scheduler.Worker thread.
       at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:54)
       at android.os.Handler.handleCallback(Handler.java:739)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:145)
       at android.app.ActivityThread.main(ActivityThread.java:5938)
       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:1389)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1184)
Caused by: d.b.i: 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.NotificationLite.accept(NotificationLite.java:147)
       at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.pollQueue(OperatorObserveOn.java:177)
       at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.access$000(OperatorObserveOn.java:65)
       at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber$2.call(OperatorObserveOn.java:153)
       at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:47)
       at android.os.Handler.handleCallback(Handler.java:739)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:145)
       at android.app.ActivityThread.main(ActivityThread.java:5938)
       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:1389)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1184)
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.NotificationLite.accept(NotificationLite.java:147)
       at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.pollQueue(OperatorObserveOn.java:177)
       at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber.access$000(OperatorObserveOn.java:65)
       at rx.internal.operators.OperatorObserveOn$ObserveOnSubscriber$2.call(OperatorObserveOn.java:153)
       at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:47)
       at android.os.Handler.handleCallback(Handler.java:739)
       at android.os.Handler.dispatchMessage(Handler.java:95)
       at android.os.Looper.loop(Looper.java:145)
       at android.app.ActivityThread.main(ActivityThread.java:5938)
       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:1389)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1184)
Caused by: d.b.c: Chain of Causes for CompositeException In Order Received =>
       at com.crashlytics.android.core.SessionDataWriter.getEventAppExecutionExceptionSize(SessionDataWriter.java:597)
       at com.crashlytics.android.core.SessionDataWriter.getEventAppExecutionExceptionSize(SessionDataWriter.java:600)
       at com.crashlytics.android.core.SessionDataWriter.getEventAppExecutionExceptionSize(SessionDataWriter.java:600)
       at com.crashlytics.android.core.SessionDataWriter.getEventAppExecutionSize(SessionDataWriter.java:533)
       at com.crashlytics.android.core.SessionDataWriter.getEventAppSize(SessionDataWriter.java:492)
       at com.crashlytics.android.core.SessionDataWriter.getSessionEventSize(SessionDataWriter.java:473)
       at com.crashlytics.android.core.SessionDataWriter.writeSessionEvent(SessionDataWriter.java:195)
       at com.crashlytics.android.core.CrashlyticsUncaughtExceptionHandler.writeSessionEvent(CrashlyticsUncaughtExceptionHandler.java:1038)
       at com.crashlytics.android.core.CrashlyticsUncaughtExceptionHandler.writeFatal(CrashlyticsUncaughtExceptionHandler.java:395)
       at com.crashlytics.android.core.CrashlyticsUncaughtExceptionHandler.handleUncaughtException(CrashlyticsUncaughtExceptionHandler.java:298)
       at com.crashlytics.android.core.CrashlyticsUncaughtExceptionHandler.access$102(CrashlyticsUncaughtExceptionHandler.java:56)
       at com.crashlytics.android.core.CrashlyticsUncaughtExceptionHandler$7.call(CrashlyticsUncaughtExceptionHandler.java:278)
       at com.crashlytics.android.core.CrashlyticsUncaughtExceptionHandler$7.call(CrashlyticsUncaughtExceptionHandler.java:275)
       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:75)
       at io.fabric.sdk.android.services.common.BackgroundPriorityRunnable.run(BackgroundPriorityRunnable.java:30)
       at java.lang.Thread.run(Thread.java:818)
Caused by: co.ninetynine.android.core.api.e: Please check your connection…
       at co.ninetynine.android.core.api.RetrofitErrorHandler.handleError(RetrofitErrorHandler.java:37)
       at retrofit.RxSupport$2.run(RxSupport.java:59)
       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: retrofit.RetrofitError: Unable to resolve host "www.99.co": 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.99.co": No address associated with hostname
       at java.net.InetAddress.lookupHostByName(InetAddress.java:457)
       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:187)
       at com.squareup.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:156)
       at com.squareup.okhttp.internal.http.RouteSelector.next(RouteSelector.java:98)
       at com.squareup.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:344)
       at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:327)
       at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:245)
       at com.squareup.okhttp.Call.getResponse(Call.java:267)
       at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:224)
       at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:195)
       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)
Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname)
       at libcore.io.Posix.android_getaddrinfo(Posix.java)
       at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:55)
       at java.net.InetAddress.lookupHostByName(InetAddress.java:438)
       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:187)
       at com.squareup.okhttp.internal.http.RouteSelector.nextProxy(RouteSelector.java:156)
       at com.squareup.okhttp.internal.http.RouteSelector.next(RouteSelector.java:98)
       at com.squareup.okhttp.internal.http.HttpEngine.createNextConnection(HttpEngine.java:344)
       at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:327)
       at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:245)
       at com.squareup.okhttp.Call.getResponse(Call.java:267)
       at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:224)
       at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:195)
       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)
cuimingqiang

cuimingqiang commented on Oct 19, 2015

@cuimingqiang
Author

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

scana commented on Oct 20, 2015

@scana

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

sureshs592 commented on Oct 21, 2015

@sureshs592

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

erikjhordan-rey commented on Oct 29, 2015

@erikjhordan-rey

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

liu-xinhui commented on Nov 23, 2015

@liu-xinhui

@cuimingqiang @sureshs592
I get the same error

compile 'io.reactivex:rxandroid:1.0.1'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp:2.4.0'

this method do not work

RestAdapter.Builder()
.setErrorHandler(new ErrorHandler() {
@OverRide
public Throwable handleError(RetrofitError cause) {
return new Throwable(cause.getCause());
}
})

25 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @JakeWharton@IgorGanapolsky@qbraet@scana@rraallvv

        Issue actions

          RxJava Retrofit --Fatal Exception thrown on Scheduler.Worker thread. · Issue #1088 · square/retrofit