StackOverflowError when add a networkInterceptors
See original GitHub issuejava.lang.StackOverflowError at java.lang.ThreadLocal.get(ThreadLocal.java:53) at dalvik.system.BlockGuard.getThreadPolicy(BlockGuard.java:140) at libcore.io.BlockGuardOs.recvfrom(BlockGuardOs.java:163) at libcore.io.IoBridge.recvfrom(IoBridge.java:513) at java.net.PlainSocketImpl.read(PlainSocketImpl.java:488) 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: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 com.squareup.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:191) at com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:79) at com.squareup.okhttp.internal.http.HttpEngine.readNetworkResponse(HttpEngine.java:909) at com.squareup.okhttp.internal.http.HttpEngine.access$300(HttpEngine.java:93) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:894) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.library_http.RequestInterceptor.intercept(RequestInterceptor.java:27) at com.squareup.okhttp.internal.http.HttpEngine$NetworkInterceptorChain.proceed(HttpEngine.java:867) at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:748) at com.squareup.okhttp.Call.getResponse(Call.java:277) at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:234) at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:196) at com.squareup.okhttp.Call.access$100(Call.java:34) at com.squareup.okhttp.Call$AsyncCall.execute(Call.java:162) at com.squareup.okhttp.internal.NamedRunnable.run(NamedRunnable.java:33) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573) at java.lang.Thread.run(Thread.java:856)
the method in the HttpEngine and the RequestInterceptor chain.proceed() call each other
i add interceptor below this
mOkHttpClient.networkInterceptors().add(new RequestInterceptor(ctx));
this is the code of interceptor `public class RequestInterceptor implements Interceptor { private Context mCtx;
public RequestInterceptor(Context ctx) {
mCtx = ctx;
}
@Override
public Response intercept(Chain chain) throws IOException {
Request originalRequest = chain.request();
if (originalRequest.body() == null) {
return chain.proceed(originalRequest);
}
String url = originalRequest.urlString();
if (!url.contains("distinctRequestId=")) {
String requestId = OkHttpClientManager.getDistinctRequestId();
if (url.contains("?")) {
url = originalRequest.urlString() + "&distinctRequestId=" + requestId;
} else {
url = originalRequest.urlString() + "?distinctRequestId=" + requestId;
}
url = url + "&p=" + PreferenceUtils.getRequestId(mCtx) + "&span=" + PreferenceUtils.getConnectTime(mCtx);
PreferenceUtils.setRequestId(mCtx, requestId);
Request compressedRequest = originalRequest.newBuilder()
.url(url)
.build();
return chain.proceed(compressedRequest);
}
return chain.proceed(originalRequest);
}
} `
Issue Analytics
- State:
- Created 8 years ago
- Comments:28 (8 by maintainers)
Top GitHub Comments
Looks like the error I reported above can be fixed by clearing interceptors every time (thanks for chrisstewart comments above). I have run the following code more than one hour and there is no StackOverflowError any more.
Add code (Kotlin): httpClient.interceptors().clear()
The the code as following: ` private val httpClient = OkHttpClient.Builder() fun createService(serviceClass: Class, username: String?, password: String?): S? {
///////////////////////////new code if (httpClient.interceptors().isNotEmpty()) { httpClient.interceptors().clear() } ////////////////////////////////new code
val credential = Credentials.basic(username, password) val interceptor = Interceptor { chain -> val original = chain.request() val requestBuilder = original.newBuilder() .header(“Authorization”, credential) .header(“Accept”, “application/json”) .header(“Content-Type”, “application/json”) .method(original.method(), original.body()) val request = requestBuilder.build() chain.proceed(request) } httpClient.addInterceptor(interceptor) val retrofit = Retrofit.Builder().baseUrl(IEventConstant.baseUrl).addConverterFactory(GsonConverterFactory.create()).client(httpClient.build()).build()
return retrofit.create(serviceClass) } `
@XiaomeiZeng The solution of clearing interceptors maybe create a lot of repetitive same interceptors…,can be same better solution? @swankjesse