Skip to content

Commit 976605e

Browse files
committed
Simplify and not the source of a test case
1 parent 9cb51e6 commit 976605e

File tree

1 file changed

+3
-14
lines changed

1 file changed

+3
-14
lines changed

src/test/java/scala/compat/java8/FutureConvertersTest.java

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -320,23 +320,12 @@ public void testToJavaExceptionally() throws InterruptedException,
320320
@Test
321321
public void testToJavaThenComposeWithToJavaThenAccept() throws InterruptedException,
322322
ExecutionException, TimeoutException {
323+
// Test case from https://github.com/scala/scala-java8-compat/issues/29
323324
final Promise<String> p1 = promise();
324325
final CompletableFuture<String> future = new CompletableFuture<>();
325326

326-
final CompletionStage<String> second =
327-
CompletableFuture.supplyAsync(() -> "Hello").
328-
thenCompose(x -> toJava(p1.future()));
329-
330-
second.handle((x, t) -> {
331-
if (t != null) {
332-
t.printStackTrace();
333-
future.completeExceptionally(t);
334-
} else {
335-
future.complete(x);
336-
}
337-
return null;
338-
});
339-
327+
CompletableFuture.supplyAsync(() -> "Hello").
328+
thenCompose(x -> toJava(p1.future())).handle((x, t) -> future.complete(x));
340329
p1.success("Hello");
341330
assertEquals("Hello", future.get(1000, MILLISECONDS));
342331
}

0 commit comments

Comments
 (0)