--

You've forgotten one key thing. The OkHttp client has a fix number of dispatchers, that is the actual thread that the API call is made on. (The fixed value is 5 or 10 or something like that, I can't recall.) If all dispatchers hit a 401 simultaneously then there are no more available when the refresh token API call is made. You can increase the number of dispatchers the client has but that ultimately doesn't solve the problem.

The api client to get the refresh token should have it's own unique OkHTTP client with it's own set of dispatchers that are independent from the rest of the "main" set. This way when it comes time to refresh a token there are available dispatchers no deadlock occurs.

--

--

Michael Ferguson
Michael Ferguson

Written by Michael Ferguson

Android software developer. Views and opinions expressed are my own and not that of my employer.

Responses (1)