New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stack Overflow error with Retrofit 2+ okhttp3 client #2001
Comments
Don’t add multiple copies of the same interceptor to the same OkHttpClient instance. |
The below code is used for initiating retrofit client with OkHttpClient. Could you please suggest which you refer for "multiple copies of the same interceptor to the same OkHttpClient instance". Thanks in advance. Retrofit Initialising Code: |
Maybe I’m mistaken. Is your CustomAuthenticator re-entrant? |
Yes, I also attached the CustomAuthenticator class for your reference. Custom Authenticator Code: |
You should probably not make HTTP calls that use your interceptor from within your interceptor. That’s called infinite recursion and it’s very slow. |
Issue Log:
OkHttp DispatcherFATAL EXCEPTION: OkHttp Dispatcher
Process: com.mallow.xxx.xxx.dev, PID: 28874
java.lang.StackOverflowError
at java.lang.String.startsWith(String.java:1428)
at java.lang.String.startsWith(String.java:1411)
at java.net.URI.isValidHost(URI.java:521)
at java.net.URI.parseAuthority(URI.java:491)
at java.net.URI.parseURI(URI.java:409)
at java.net.URI.(URI.java:204)
at okhttp3.HttpUrl.uri(Unknown)
at okhttp3.internal.http.RouteSelector.resetNextProxy(Unknown)
at okhttp3.internal.http.RouteSelector.(Unknown)
at okhttp3.internal.http.StreamAllocation.(Unknown)
at okhttp3.internal.http.HttpEngine.(Unknown)
at okhttp3.RealCall.getResponse(Unknown)
at okhttp3.RealCall$ApplicationInterceptorChain.proceed(Unknown)
at com.mallow.xxx.xxx.retrofit.xxxRestClient.-com_mallow_xxx_xxx_retrofit_xxxRestClient_lambda$1(xxxRestClient.java:89)
at com.mallow.xxx.xxx.retrofit.xxxRestClient$-retrofit2_Retrofit_getRetrofitClient__LambdaImpl0.intercept(xxxRestClient.java)
at okhttp3.RealCall$ApplicationInterceptorChain.proceed(Unknown)
at okhttp3.RealCall.getResponseWithInterceptorChain(Unknown)
at okhttp3.RealCall.execute(Unknown)
at retrofit2.OkHttpCall.execute(Unknown)
at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall.execute(Unknown)
at com.mallow.xxx.xxx.retrofit.xxxRestClient$CustomAuthenticator.authenticate(xxxRestClient.java:215)
at okhttp3.internal.http.HttpEngine.followUpRequest(Unknown)
at okhttp3.RealCall.getResponse(Unknown)
at okhttp3.RealCall$ApplicationInterceptorChain.proceed(Unknown)
at com.mallow.xxx.xxx.retrofit.xxxRestClient.-com_mallow_xxx_xxx_retrofit_xxxRestClient_lambda$1(xxxRestClient.java:89)
at com.mallow.xxx.xxx.retrofit.xxxRestClient$-retrofit2_Retrofit_getRetrofitClient__LambdaImpl0.intercept(xxxRestClient.java)
at okhttp3.RealCall$ApplicationInterceptorChain.proceed(Unknown)
at okhttp3.RealCall.getResponseWithInterceptorChain(Unknown)
at okhttp3.RealCall.execute(Unknown)
at retrofit2.OkHttpCall.execute(Unknown)
at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall.execute(Unknown)
at com.mallow.xxx.xxx.retrofit.xxxRestClient$CustomAuthenticator.authenticate(xxxRestClient.java:215)
at okhttp3.internal.http.HttpEngine.followUpRequest(Unknown)
at okhttp3.RealCall.getResponse(Unknown)
at okhttp3.RealCall$ApplicationInterceptorChain.proceed(Unknown)
at com.mallow.xxx.xxx.retrofit.xxxRestClient.-com_mallow_xxx_xxx_retrofit_xxxRestClient_lambda$1(xxxRestClient.java:89)
at com.mallow.xxx.xxx.retrofit.xxxRestClient$-retrofit2_Retrofit_getRetrofitClient__LambdaImpl0.intercept(xxxRestClient.java)
at okhttp3.RealCall$ApplicationInterceptorChain.proceed(Unknown)
at okhttp3.RealCall.getResponseWithInterceptorChain(Unknown)
at okhttp3.RealCall.execute(Unknown)
at retrofit2.OkHttpCall.execute(Unknown)
at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall.execute(Unknown)
at com.mallow.xxx.xxx.retrofit.xxxRestClient$CustomAuthenticator.authenticate(xxxRestClient.java:215)
at okhttp3.internal.http.HttpEngine.followUpRequest(Unknown)
at okhttp3.RealCall.getResponse(Unknown)
at okhttp3.RealCall$ApplicationInterceptorChain.proceed(Unknown)
at com.mallow.xxx.xxx.retrofit.xxxRestClient.-com_mallow_xxx_xxx_retrofit_xxxRestClient_lambda$1(xxxRestClient.java:89)
at com.mallow.xxx.xxx.retrofit.xxxRestClient$-retrofit2_Retrofit_getRetrofitClient__LambdaImpl0.intercept(xxxRestClient.java)
at okhttp3.RealCall$ApplicationInterceptorChain.proceed(Unknown)
at okhttp3.RealCall.getResponseWithInterceptorChain(Unknown)
at okhttp3.RealCall.execute(Unknown)
at retrofit2.OkHttpCall.execute(Unknown)
at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall.execute(Unknown)
at com.mallow.xxx.xxx.retrofit.xxxRestClient$CustomAuthenticator.authenticate(xxxRestClient.java:215)
at okhttp3.internal.http.HttpEngine.followUpRequest(Unknown)
at okhttp3.RealCall.getResponse(Unknown)
at okhttp3.RealCall$ApplicationInterceptorChain.proceed(Unknown)
at com.mallow.xxx.xxx.retrofit.xxxRestClient.-com_mallow_xxx_xxx_retrofit_xxxR
The text was updated successfully, but these errors were encountered: