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.

Retry on any exception except excluded ones

See original GitHub issue

Hi, it will be nice to have a method like: retryOnAnyExceptionExcluding(Class<? extends Exception>... exceptions)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mkopyleccommented, Oct 17, 2017

Couple of issues here.

    public static void main(String[] args) {
        RetryConfig config = new RetryConfigBuilder()
                .withMaxNumberOfTries(3)
                .withNoWaitBackoff()
                .withDelayBetweenTries(0, ChronoUnit.MILLIS)
                .retryOnAnyExceptionExcluding(RuntimeException.class)
                .build();
        new CallExecutor<String>(config).execute(() -> {
            throw new Exception("error");
        });
    }

This code is throwing UnexpectedException but it should retry. UnexpectedException should be thrown if RuntimeException is thrown from callable.

Now this code:

    public static void main(String[] args) {
        RetryConfig config = new RetryConfigBuilder()
                .withMaxNumberOfTries(3)
                .withNoWaitBackoff()
                .withDelayBetweenTries(0, ChronoUnit.MILLIS)
                .retryOnAnyExceptionExcluding(RuntimeException.class)
                .build();
        new CallExecutor<String>(config).execute(() -> {
            throw new IllegalStateException("error");
        });
    }

should not retry on IllegalStateException because it extends from RuntimeException.

0reactions
mkopyleccommented, Oct 26, 2017

Thanks for fast issue solving 😃 I’ll check that out soon.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Trying to exclude an exception using @Retryable
I will try adding a blanket @Recover method. So I put in a catch-all @Recover method and the exception it is getting is...
Read more >
Configuring exceptions to exclude from retry (using annotations)
In this post, I will show with example how to mention the exceptions through annotation, that when thrown by a annotated operation, Spring...
Read more >
Retryable won't work as expected with exclude #74 - GitHub
My interpretation is that only when both exclude and include are missing it retries all exceptions. But this is not clearly document and...
Read more >
Exception Handling and Retries - Amazon Neptune
When transactions are canceled because of unresolvable conflicts or lock-wait timeouts, Amazon Neptune responds with a ConcurrentModificationException .
Read more >
Skip-Record, Retry-Step - IBM
Now the two exclude exceptions will not be considered for skipping, but all others will. The include.exception property is mutually exclusive of the...
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