Okhttp: java.lang.NullPointerException:BridgeInterceptor.intercept

Created on 31 Oct 2016  路  7Comments  路  Source: square/okhttp

It occurs a lot, But I can not locate the row that occurred, Can anyone help me out please.

java.lang.NullPointerException
    at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java)
    at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java)
                                                         recover(RetryAndFollowUpInterceptor.java)
                                                         isRecoverable(RetryAndFollowUpInterceptor.java)
                                                         sameConnection(RetryAndFollowUpInterceptor.java)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java)
    at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java)
    at okhttp3.RealCall.access$100(RealCall.java)
    at okhttp3.RealCall$AsyncCall.execute(RealCall.java)
    at okhttp3.internal.NamedRunnable.run(NamedRunnable.java)
    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:838)

Most helpful comment

@jaspreet84 please fix your cookie jar to not return null when it should return an empty list.

All 7 comments

Are you on the latest version? Sadly without line numbers in the stack trace there鈥檚 not much I can do. Maybe provide a test case?

@swankjesse The latest version 3.4.1

@swankjesse Is it possible Content-Length == 0? In this case HttpHeaders.hasBody will return true. But networkResponse.body() == null.

We don鈥檛 treat an empty body any differently.

Can you provide a test case to demonstrate the problem?

I'm on Okhttp 3.5.0 and still see this issue. Important to note that it happens only after I add a cookie to cookiemanager of client:

Exception in thread "main" java.lang.NullPointerException
at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:85)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:120)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:212)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:179)
at okhttp3.RealCall.execute(RealCall.java:63)
at com.zscaler.qa.ztaap.business.Authentication.main(Authentication.java:55)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

Please let me know if more info is needed

@jaspreet84 please fix your cookie jar to not return null when it should return an empty list.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rfc2822 picture rfc2822  路  3Comments

theotherp picture theotherp  路  3Comments

yschimke picture yschimke  路  3Comments

sargunv picture sargunv  路  3Comments

SandroMachado picture SandroMachado  路  3Comments