@Test public void retries_if_there_is_a_flaky_exception() throws IOException { AtomicInteger invocation = new AtomicInteger(0); String result = Resilient.tryRepeatedly(10, () -> { if (invocation.incrementAndGet() == 1) { throw new IOException("dummy exception"); } return "result"; }); assertThat(result, is("result")); }
public static <T> T tryRepeatedly(IoAction<T> action) throws IOException { return tryRepeatedly(10, action); }
Resilient { public static <T> T tryRepeatedly(IoAction<T> action) throws IOException { return tryRepeatedly(10, action); } }
Resilient { public static <T> T tryRepeatedly(IoAction<T> action) throws IOException { return tryRepeatedly(10, action); }  }
Resilient { public static <T> T tryRepeatedly(IoAction<T> action) throws IOException { return tryRepeatedly(10, action); }  static T tryRepeatedly(IoAction<T> action); static T tryRepeatedly(int maxTries, IoAction<T> action); }
Resilient { public static <T> T tryRepeatedly(IoAction<T> action) throws IOException { return tryRepeatedly(10, action); }  static T tryRepeatedly(IoAction<T> action); static T tryRepeatedly(int maxTries, IoAction<T> action);  }