Created
November 27, 2017 15:18
-
-
Save babjo/6b37572661311bff03581b3f4b8a365d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String name = null; | |
// ... | |
CompletableFuture<String> completableFuture | |
= CompletableFuture.supplyAsync(() -> { | |
if (name == null) { | |
throw new RuntimeException("Computation error!"); | |
} | |
return "Hello, " + name; | |
})}).handle((s, t) -> s != null ? s : "Hello, Stranger!"); | |
assertEquals("Hello, Stranger!", completableFuture.get()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment