Skip to main content

Practice ยท 1 of 3

Compose a Pipeline

Implement inside Solution (synchronous executor is fine โ€” CompletableFuture.completedFuture chains run inline): - static CompletableFuture<Integer> pipeline(int base): completedFuture(base) โ†’ thenApply(x -> x * 2) โ†’ thenApply(x -> x + 1) - static CompletableFuture<Integer> combine(int a, int b): thenCombine of two completed pipelines, summed - static CompletableFuture<Integer> safeDivide(int a, int b): completedFuture of a/b inside the chain, exceptionally returning -1 on ArithmeticException Join results with .join() in the tests โ€” completed chains return immediately.

Difficulty: intermediate

Back to lesson: Practice: Async & HTTP Lab