Feign Default Retryer retries without sleep when thread gets interrupted
See original GitHub issueHi, I found the problem in method continueOrPropagate in class Retryer.Default. When the thread in which Retryer is running gets interrupted, Retryer performs retrying without sleep. Flow looks like that:
- Thread gets interrupted
- The next attempt is performed if maxAttepts is not yet met
- Thread should sleep for a given interval - but it’s already interrupted so the InterruptedException is thrown
- Current thread gets interrupted and retrying is performed again.
The following procedure is performed until the higher level methods/thread groups handle interruption which can take some time and lead to fleed of retrials.
In my opinion, this situation should be handled (for example by propagation of RetryableException).
public void continueOrPropagate(RetryableException e) {
if (attempt++ >= maxAttempts) {
throw e;
}
long interval;
if (e.retryAfter() != null) {
interval = e.retryAfter().getTime() - currentTimeMillis();
if (interval > maxPeriod) {
interval = maxPeriod;
}
if (interval < 0) {
return;
}
} else {
interval = nextMaxInterval();
}
try {
Thread.sleep(interval);
} catch (InterruptedException ignored) {
Thread.currentThread().interrupt();
}
sleptForMillis += interval;
}
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Retrying Feign Calls - Baeldung
Learn how to retry REST API calls with Feign library. ... e) { try { Thread.sleep(1000L); } catch (InterruptedException ex) { Thread.
Read more >How to Customize Feign's Retry Mechanism - Medium
Inside the decode method on first conditional block we are checking if the raised exception is already a retryable exception or not. If...
Read more >Feign client and Spring retry - Stack Overflow
I prepared a blog post about using Spring Retry with Feign Client methods. ... GET}) public Object test() throws InterruptedException ...
Read more >feign.Retryer$Default java code examples - Tabnine
Retryer $Default (Showing top 18 results out of 315) ... nextMaxInterval(); } try { Thread.sleep(interval); } catch (InterruptedException ignored) { Thread.
Read more >Retryer.java example - Javatips.net
... retry operations should continue or not. */ public interface Retryer extends Cloneable { /** * if retry is permitted, return (possibly after...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
ping @adriancole
ping @adriancole