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.

Feign Default Retryer retries without sleep when thread gets interrupted

See original GitHub issue

Hi, 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:

  1. Thread gets interrupted
  2. The next attempt is performed if maxAttepts is not yet met
  3. Thread should sleep for a given interval - but it’s already interrupted so the InterruptedException is thrown
  4. 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:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
spencergibbcommented, Jan 17, 2018
0reactions
MichalSzewczykcommented, Jan 24, 2018
Read more comments on GitHub >

github_iconTop 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 >

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