@@ -0,0 +1,1146 @@
+package net.jodah.recurrent.issues;%0A%0Aimport java.util.concurrent.Executors;%0Aimport java.util.concurrent.ScheduledExecutorService;%0Aimport java.util.concurrent.TimeUnit;%0A%0Aimport org.testng.annotations.Test;%0A%0Aimport net.jodah.concurrentunit.Waiter;%0Aimport net.jodah.recurrent.Recurrent;%0Aimport net.jodah.recurrent.RecurrentFuture;%0Aimport net.jodah.recurrent.RetryPolicy;%0A%0A@Test%0Apublic class Issue5 %7B%0A  /**%0A   * Asserts that a failure is handled as expected by a listener registered via whenFailure.%0A   */%0A  public void test() throws Throwable %7B%0A    Waiter waiter = new Waiter();%0A    Exception failureToThrow = new RuntimeException();%0A%0A    RetryPolicy retryPolicy = new RetryPolicy().withDelay(100, TimeUnit.MILLISECONDS)%0A        .withMaxDuration(2, TimeUnit.SECONDS)%0A        .withMaxRetries(3);%0A    ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();%0A    RecurrentFuture%3C?%3E run = Recurrent.get(() -%3E %7B%0A      throw failureToThrow;%0A    %7D , retryPolicy, executor);%0A    run.whenFailure((result, failure) -%3E %7B%0A      waiter.assertEquals(failureToThrow, failure);%0A      waiter.resume();%0A    %7D);%0A%0A    waiter.await(1000);%0A  %7D%0A%7D%0A

Test to assert correct behavior for issue #5.