question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OnErrorNotImplementedException when Interceptor throws.

See original GitHub issue

I get this exception any time there’s SocketTimeoutException. Using Retrofit2, RxJava 1.1.0, OkHttp3.

FATAL EXCEPTION: RxCachedThreadScheduler-1
                                                                   Process: com.***, PID: 13298
                                                                   java.lang.IllegalStateException: Exception thrown on Scheduler.Worker thread. Add `onError` handling.
                                                                       at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:60)
                                                                       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
                                                                       at java.util.concurrent.FutureTask.run(FutureTask.java:237)
                                                                       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269)
                                                                       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
                                                                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
                                                                       at java.lang.Thread.run(Thread.java:818)
                                                                    Caused by: rx.exceptions.OnErrorNotImplementedException
                                                                       at rx.Observable$27.onError(Observable.java:8139)
                                                                       at rx.observers.SafeSubscriber._onError(SafeSubscriber.java:157)
                                                                       at rx.observers.SafeSubscriber.onError(SafeSubscriber.java:120)
                                                                       at rx.internal.operators.OperatorSubscribeOn$1$1.onError(OperatorSubscribeOn.java:59)
                                                                       at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$CallOnSubscribe.call(RxJavaCallAdapterFactory.java:151)
                                                                       at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$CallOnSubscribe.call(RxJavaCallAdapterFactory.java:125)
                                                                       at rx.Observable.unsafeSubscribe(Observable.java:8314)
                                                                       at rx.internal.operators.OperatorSubscribeOn$1.call(OperatorSubscribeOn.java:94)
                                                                       at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
                                                                       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423) 
                                                                       at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
                                                                       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269) 
                                                                       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
                                                                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
                                                                       at java.lang.Thread.run(Thread.java:818) 
                                                                    Caused by: java.net.SocketTimeoutException
                                                                       at java.net.PlainSocketImpl.read(PlainSocketImpl.java:484)
                                                                       at java.net.PlainSocketImpl.-wrap0(PlainSocketImpl.java)
                                                                       at java.net.PlainSocketImpl$PlainSocketInputStream.read(PlainSocketImpl.java:237)
                                                                       at okio.Okio$2.read(Okio.java:139)
                                                                       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 okhttp3.internal.http.Http1xStream.readResponse(Http1xStream.java:184)
                                                                       at okhttp3.internal.http.Http1xStream.readResponseHeaders(Http1xStream.java:125)
                                                                       at okhttp3.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:723)
                                                                       at okhttp3.internal.http.HttpEngine.access$200(HttpEngine.java:81)
                                                                       at okhttp3.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:708)
                                                                       at com.***.network.interceptor.HeaderInterceptor.intercept(HeaderInterceptor.java:24)
                                                                       at okhttp3.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:681)
                                                                       at okhttp3.internal.http.HttpEngine.readResponse(HttpEngine.java:563)
                                                                       at okhttp3.RealCall.getResponse(RealCall.java:241)
                                                                       at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:198)
                                                                       at com.***.network.interceptor.TokenExpiredInterceptor.intercept(TokenExpiredInterceptor.java:40)
                                                                       at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187)
                                                                       at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:203)
                                                                       at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187)
                                                                       at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:160)
                                                                       at okhttp3.RealCall.execute(RealCall.java:57)
                                                                       at retrofit2.OkHttpCall.execute(OkHttpCall.java:174)
                                                                       at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$CallOnSubscribe.call(RxJavaCallAdapterFactory.java:144)
                                                                       at retrofit2.adapter.rxjava.RxJavaCallAdapterFactory$CallOnSubscribe.call(RxJavaCallAdapterFactory.java:125) 
                                                                       at rx.Observable.unsafeSubscribe(Observable.java:8314) 
                                                                       at rx.internal.operators.OperatorSubscribeOn$1.call(OperatorSubscribeOn.java:94) 
                                                                       at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55) 
                                                                       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423) 
                                                                       at java.util.concurrent.FutureTask.run(FutureTask.java:237) 
                                                                       at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:269) 
                                                                       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
                                                                       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
                                                                       at java.lang.Thread.run(Thread.java:818) 

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
mcwienczekcommented, Apr 24, 2017

I’ve had the same problem. Unfortunately catching and returning null as Xuzhiwei proposed did not help me. Getting NullReferenceException from Observable on the other hand.

2reactions
bulatgaleevcommented, Jun 1, 2016

RxLint for the rescue!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I handle HTTP errors like 401, 403 ... - Stack Overflow
I'm using Retrofit , OK-HTTP and RxJava2 to handle network calls, I created below interceptor to handle the Network error response for each ......
Read more >
The RxJava2 Default Error Handler | by Bryan Herbst | Medium
OnErrorNotImplementedException is one of the “bug” cases that RxJava ... As the name may imply, RxJava throws an UndeliverableException when ...
Read more >
WSS Connection Timeout Randomly - Infura Community
Problem is that, it randomly throws connection timeout exception. ... CallServerInterceptor.intercept(CallServerInterceptor.java:75)
Read more >
java.lang.NullPointerException.<init> java code examples
Customizes the {@code Throwable} with a custom message and wraps it before it * is signalled to the {@code RxJavaPlugins.onError()} handler as {@code ......
Read more >
OKHttp Error Interceptors, RxJava 2, Repository Pattern, Retrofit
Android REST Tutorial - OKHttp Error Interceptors, RxJava 2, ... to help handle REST Adapter Errors (Note: errors thrown here will propagate ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found