failsafe-lib / failsafe

Fault tolerance and resilience patterns for the JVM
https://failsafe.dev
Apache License 2.0
4.16k stars 295 forks source link

Failsafe okhttp integration causes issues with BearerAuth and outdated tokens #383

Open shauser opened 2 months ago

shauser commented 2 months ago

When using HttpBearerAuth with any type of expiring / non-reusable tokens the default setup as documented on https://failsafe.dev/okhttp/ causes issues: It can happen that a circuit breaker or retry policy causes enough delay for the token to expire.

It seems that the only way to address this right now is to check for status 401 and then re-create the call and executor, which causes the retry policy to be reset.