Ensure RetryTaskTests compiles in Eclipse IDE

Prior to this commit, "new RetryTask<>" declarations whose
TaskCallbacks (implemented as lambda expressions) did not actually
throw an exception resulted in a compilation error in Eclipse:

  "Unhandled exception type Exception".

This is due to the fact that RetryTask is declared with "E extends
Exception", and the Eclipse compiler therefore infers that the lambda
expression potentially throws a checked Exception.

To address that, this commit explicitly declares that the affected
lambda expressions throw unchecked RuntimeExceptions:

  "new RetryTask<String, RuntimeException>"
This commit is contained in:
Sam Brannen
2026-01-25 17:46:14 +01:00
parent e56f7c1e53
commit 9e4a54bb99
@@ -52,7 +52,7 @@ class RetryTaskTests {
@Test
void syncTaskWithImmediateSuccess() {
assertThat(
syncExecutor.execute(new RetryTask<>(() -> {
syncExecutor.execute(new RetryTask<String, RuntimeException>(() -> {
invocationCount.incrementAndGet();
return "always succeeds";
}, retryPolicy)))
@@ -63,7 +63,7 @@ class RetryTaskTests {
@Test
void syncTaskWithSuccessAfterInitialFailures() {
assertThat(
syncExecutor.execute(new RetryTask<>(() -> {
syncExecutor.execute(new RetryTask<String, RuntimeException>(() -> {
if (invocationCount.incrementAndGet() < 2) {
throw new IllegalStateException("Boom " + invocationCount.get());
}