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.

NullPointerException in OkHttp Dispatcher

See original GitHub issue

I keep getting this NullPointerException whenever I use the OkHttpClient.

Exception in thread "OkHttp Dispatcher" java.lang.NullPointerException
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187)
    at com.microsoft.rest.credentials.TokenCredentialsInterceptor.sendRequestWithAuthorization(TokenCredentialsInterceptor.java:49)
    at com.microsoft.rest.credentials.TokenCredentialsInterceptor.intercept(TokenCredentialsInterceptor.java:37)
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187)
    at com.microsoft.rest.credentials.TokenCredentialsInterceptor.sendRequestWithAuthorization(TokenCredentialsInterceptor.java:49)
    at com.microsoft.rest.credentials.TokenCredentialsInterceptor.intercept(TokenCredentialsInterceptor.java:37)
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187)
    at com.microsoft.azure.CustomHeaderInterceptor.intercept(CustomHeaderInterceptor.java:133)
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187)
    at com.microsoft.rest.credentials.TokenCredentialsInterceptor.sendRequestWithAuthorization(TokenCredentialsInterceptor.java:49)
    at com.microsoft.rest.credentials.TokenCredentialsInterceptor.intercept(TokenCredentialsInterceptor.java:37)
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187)
    at com.microsoft.azure.CustomHeaderInterceptor.intercept(CustomHeaderInterceptor.java:133)
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187)
    at com.microsoft.azure.CustomHeaderInterceptor.intercept(CustomHeaderInterceptor.java:133)
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187)
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187)
    at com.microsoft.rest.UserAgentInterceptor.intercept(UserAgentInterceptor.java:58)
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187)
    at com.microsoft.azure.CustomHeaderInterceptor.intercept(CustomHeaderInterceptor.java:133)
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187)
    at com.microsoft.rest.credentials.TokenCredentialsInterceptor.sendRequestWithAuthorization(TokenCredentialsInterceptor.java:49)
    at com.microsoft.rest.credentials.TokenCredentialsInterceptor.intercept(TokenCredentialsInterceptor.java:37)
    at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:187)
    at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:160)
    at okhttp3.RealCall.access$100(RealCall.java:30)
    at okhttp3.RealCall$AsyncCall.execute(RealCall.java:127)
    at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

I don’t get it regularly, but I do encounter this issue at least once in 3 runs.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jianghaolucommented, Oct 24, 2017

390 days later - please reopen if it’s still an issue.

0reactions
jianghaolucommented, Sep 29, 2016

@gadagip By default, we add UserAgentInterceptor, RetryHander, a CustomerHeaderInterceptor including a request ID. You can add interceptors by all means. But it seems weird why your stack trace is so complicated, with even multiple hits of the credentials interceptor.

One thing that might be helpful to try is to inspect the value of httpClient.interceptors() right before you make the actual REST call. You might also want to try removing some of the interceptors.

As a quick test on my side, I created 2 http clients and 2 compute clients, running asynchronously for 50 calls. But I couldn’t reproduce it.

If you are just using virtual machines, I also recommend you taking a look at a sample written with 1.0.0-beta2 version of the SDK. We’ve simplified the process of creating a client and configuring on it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Retrofit FATAL EXCEPTION: OkHttp Dispatcher, java.lang ...
FATAL EXCEPTION: OkHttp Dispatcher Process: , PID: 24400 java.lang.NullPointerException: interceptor RestClient$1@301dd345 returned null at ...
Read more >
Fatal Exception Okhttp dispathcer and Null Pointer Exception
Hi Vamshi. The issue is in your getCurrentDetail() method. You are declaring and initialising the currentWeather variable inside your try block ...
Read more >
Java client: NullPointerException in thread "OkHttp Dispatcher ...
I have been trying to connect to server through proxy and have gotten connection timeout. But during handle that error java-client library ...
Read more >
Change Log - OkHttp
New: QueueDispatcher.clear() may be used to reset a MockWebServer instance. ... This would have appeared in crash logs as NullPointerException: bio == null...
Read more >
一个小技巧提升OkHttp 请求稳定性
E AndroidRuntime: FATAL EXCEPTION: OkHttp Dispatcher E AndroidRuntime: Process: ... NullPointerException: blablabla E AndroidRuntime: at ...
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