package net.jodah.failsafe.issues;

import net.jodah.failsafe.Failsafe;
import net.jodah.failsafe.RetryPolicy;
import net.jodah.failsafe.Testing;
import org.testng.annotations.Test;

import java.util.concurrent.atomic.AtomicInteger;

import static org.testng.Assert.assertEquals;

@Test
public class Issue240Test {
  public void test() {
    AtomicInteger counter = new AtomicInteger();
    RetryPolicy<Object> rp = new RetryPolicy<>().handle(IllegalArgumentException.class)
      .withMaxRetries(2)
      .handleResult(null);

    Testing.ignoreExceptions(() -> {
      Failsafe.with(rp).get(() -> {
        counter.incrementAndGet();
        throw new IllegalStateException();
      });
    });

    assertEquals(counter.get(), 1);
  }
}

@@ -326,16 +326,28 @@
 oid test
+HandleResult
 () %7B%0A   
@@ -742,11 +742,444 @@
  1);%0A  %7D
+%0A%0A  public void testAbortWhen() %7B%0A    AtomicInteger counter = new AtomicInteger();%0A    RetryPolicy%3CObject%3E rp = new RetryPolicy%3C%3E().handle(IllegalArgumentException.class)%0A      .withMaxRetries(2)%0A      .abortWhen(null);%0A%0A    Testing.ignoreExceptions(() -%3E %7B%0A      Failsafe.with(rp).get(() -%3E %7B%0A        counter.incrementAndGet();%0A        throw new IllegalArgumentException();%0A      %7D);%0A    %7D);%0A%0A    assertEquals(counter.get(), 3);%0A  %7D
 %0A%7D%0A

Add another test case for issue #240.