diff --git a/src/main/java/com/spotify/futures/CompletableFuturesExtra.java b/src/main/java/com/spotify/futures/CompletableFuturesExtra.java index 398405f..c93b17e 100644 --- a/src/main/java/com/spotify/futures/CompletableFuturesExtra.java +++ b/src/main/java/com/spotify/futures/CompletableFuturesExtra.java @@ -97,14 +97,14 @@ public static CompletableFuture exceptionallyCompletedFuture(Throwable th */ public static CompletionStage handleCompose( CompletionStage future, - final BiFunction> fn) { + final BiFunction> fn) { final CompletableFuture result = new CompletableFuture(); future.whenComplete(new BiConsumer() { @Override public void accept(T value, Throwable throwable) { - final CompletionStage newStage; + final CompletionStage newStage; try { newStage = fn.apply(value, throwable); } catch (Throwable e) { @@ -149,10 +149,10 @@ public void accept(U value, Throwable throwable) { */ public static CompletionStage exceptionallyCompose( CompletionStage future, - final Function> fn) { - return handleCompose(future, new BiFunction>() { + final Function> fn) { + return handleCompose(future, new BiFunction>() { @Override - public CompletionStage apply(T value, Throwable throwable) { + public CompletionStage apply(T value, Throwable throwable) { if (throwable != null) { return fn.apply(throwable); } else { @@ -169,12 +169,12 @@ public CompletionStage apply(T value, Throwable throwable) { * @return the completion stage of a value */ public static CompletionStage dereference( - CompletionStage> future) { + CompletionStage> future) { return handleCompose(future, - new BiFunction, Throwable, CompletionStage>() { + new BiFunction, Throwable, CompletionStage>() { @Override - public CompletionStage apply( - CompletionStage value, Throwable throwable) { + public CompletionStage apply( + CompletionStage value, Throwable throwable) { return value; } }); diff --git a/src/test/java/com/spotify/futures/jdk8/CompletableFuturesExtraTest.java b/src/test/java/com/spotify/futures/jdk8/CompletableFuturesExtraTest.java index f3f51a5..1471bcb 100644 --- a/src/test/java/com/spotify/futures/jdk8/CompletableFuturesExtraTest.java +++ b/src/test/java/com/spotify/futures/jdk8/CompletableFuturesExtraTest.java @@ -232,9 +232,9 @@ public CompletionStage apply(Throwable throwable) { public void testHandleCompose() throws Exception { final CompletionStage future = CompletableFuturesExtra.exceptionallyCompletedFuture(new IllegalArgumentException()); - final CompletionStage composed = CompletableFuturesExtra.handleCompose(future, new BiFunction>() { + final CompletionStage composed = CompletableFuturesExtra.handleCompose(future, new BiFunction>() { @Override - public CompletionStage apply(String s, Throwable throwable) { + public CompletionStage apply(String s, Throwable throwable) { return CompletableFuture.completedFuture("hello"); } }); @@ -247,9 +247,9 @@ public CompletionStage apply(String s, Throwable throwable) { public void testHandleComposeFailure() throws Exception { final CompletionStage future = CompletableFuturesExtra.exceptionallyCompletedFuture(new IllegalArgumentException()); - final CompletionStage composed = CompletableFuturesExtra.handleCompose(future, new BiFunction>() { + final CompletionStage composed = CompletableFuturesExtra.handleCompose(future, new BiFunction>() { @Override - public CompletionStage apply(String s, Throwable throwable) { + public CompletionStage apply(String s, Throwable throwable) { return CompletableFuturesExtra.exceptionallyCompletedFuture(new IllegalStateException()); } }); @@ -261,9 +261,9 @@ public CompletionStage apply(String s, Throwable throwable) { public void testHandleComposeThrows() throws Exception { final CompletionStage future = CompletableFuturesExtra.exceptionallyCompletedFuture(new IllegalArgumentException()); - final CompletionStage composed = CompletableFuturesExtra.handleCompose(future, new BiFunction>() { + final CompletionStage composed = CompletableFuturesExtra.handleCompose(future, new BiFunction>() { @Override - public CompletionStage apply(String s, Throwable throwable) { + public CompletionStage apply(String s, Throwable throwable) { throw new IllegalStateException(); } }); @@ -275,9 +275,9 @@ public CompletionStage apply(String s, Throwable throwable) { public void testHandleComposeReturnsNull() throws Exception { final CompletionStage future = CompletableFuturesExtra.exceptionallyCompletedFuture(new IllegalArgumentException()); - final CompletionStage composed = CompletableFuturesExtra.handleCompose(future, new BiFunction>() { + final CompletionStage composed = CompletableFuturesExtra.handleCompose(future, new BiFunction>() { @Override - public CompletionStage apply(String s, Throwable throwable) { + public CompletionStage apply(String s, Throwable throwable) { return null; } });