guava-retrying icon indicating copy to clipboard operation
guava-retrying copied to clipboard

Is there a way to do this on something that is not a callable?

Open mayooran99 opened this issue 8 years ago • 5 comments
trafficstars

I have this requirement where I have around 4 methods all of which need to retry of certain exception. But since the execution sequence of these methods is specified, they cannot be retried on separate callables. Is there a solution for this problem through this library? That is retry methods and not callables.

mayooran99 avatar Jan 27 '17 09:01 mayooran99

You could at least use Callable<Void>.

JensRantil avatar Jan 27 '17 15:01 JensRantil

but that would still execute everything on a separate thread right? I mean each and every method which need this retry mechanism? Because all of them have to run in the same thread.

mayooran99 avatar Jan 28 '17 02:01 mayooran99

but that would still execute everything on a separate thread right?

No. Using a Callable<?> (or Runnable for that matter) doesn't mean it's run as a new thread. They are simple interfaces just like any other interface in Java. Also, the Retryer is running in the same thread as the caller.

JensRantil avatar Jan 28 '17 11:01 JensRantil

@JensRantil was right.

@mayooran99 you may find the default block strategy is ThreadSleepStrategy, it simply calls Thread.sleep()

qct avatar Mar 22 '17 09:03 qct

If I've read the original issue description correctly, I believe this issue can be closed as a "non-issue".

JensRantil avatar Mar 27 '17 10:03 JensRantil