Quantcast
Channel: User Jonathan - Stack Overflow
Viewing all articles
Browse latest Browse all 40

Answer by Jonathan for How to simplify retry code block with java 8 features

$
0
0

Using Failsafe (which I authored):

RetryPolicy retryPolicy = new RetryPolicy()  .retryOn(ExecutionException.class)  .withMaxRetries(3);Failsafe.with(retryPolicy)  .onRetry(r -> LOG.debug("retrying..."))  .withFallback(e -> LOG.debug("do something else..."))  .run(() -> someCode());

It's about as simple and expressive as you can get for your use case.


Viewing all articles
Browse latest Browse all 40

Trending Articles