Skip to content

Commit 84962ba

Browse files
committed
Update examples to check Promises.retry ambiguity
1 parent 7199d30 commit 84962ba

File tree

1 file changed

+32
-4
lines changed

1 file changed

+32
-4
lines changed

src/test/java/net/tascalate/concurrent/J8Examples.java

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,29 @@
2828

2929
public class J8Examples {
3030

31-
static BigInteger tryCalc(RetryContext<Number> ctx) {
32-
return BigInteger.ONE;
33-
}
34-
3531
public static void main(final String[] argv) throws InterruptedException, ExecutionException {
3632
final TaskExecutorService executorService = TaskExecutors.newFixedThreadPool(6);
3733

34+
@SuppressWarnings("unused")
35+
Promise<Void> t1 = Promises.retry(() -> System.out.println("Hello!"), executorService, RetryPolicy.DEFAULT);
36+
37+
@SuppressWarnings("unused")
38+
Promise<String> t2 = Promises.retry(() -> "Hello!", executorService, RetryPolicy.DEFAULT);
39+
40+
// Must be a block of code in next sample -- otherwise ambiguity
41+
@SuppressWarnings("unused")
42+
Promise<Void> t3 = Promises.retry(ctx -> {System.out.println("Hello!");}, executorService, RetryPolicy.DEFAULT);
43+
44+
@SuppressWarnings("unused")
45+
Promise<String> t4 = Promises.retry(ctx -> "Hello!", executorService, RetryPolicy.DEFAULT);
46+
47+
@SuppressWarnings("unused")
48+
Promise<Void> t5 = Promises.retry(J8Examples::nop, executorService, RetryPolicy.DEFAULT);
49+
50+
@SuppressWarnings("unused")
51+
Promise<Void> t6 = Promises.retry(J8Examples::nopCtx, executorService, RetryPolicy.DEFAULT);
52+
53+
3854
Promise<BigInteger> tryTyping = Promises.retry(
3955
J8Examples::tryCalc, executorService,
4056
RetryPolicy.<Number>create().withResultValidator(v -> v.intValue() > 0).withMaxRetries(2)
@@ -265,6 +281,18 @@ private static CompletionStage<String> pollingFutureMethod(RetryContext<String>
265281
return CompletableTask.supplyAsync(() -> "42", executor);
266282
}
267283

284+
static BigInteger tryCalc(RetryContext<Number> ctx) {
285+
return BigInteger.ONE;
286+
}
287+
288+
static void nop() {
289+
290+
}
291+
292+
static void nopCtx(RetryContext<?> ctx) {
293+
294+
}
295+
268296
private static void onComplete(int i) {
269297
System.out.println(">>> Result " + i + ", " + Thread.currentThread());
270298
}

0 commit comments

Comments
 (0)