-
Notifications
You must be signed in to change notification settings - Fork 137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example 2 with just CompletableFuture #9
Comments
@woppa684, Not bad. :D What happens if inventory.giveItem throws an exception before returning a future? For context woppa684 is responding to README.md :
|
Then that method is poorly programmed ;) |
that happens... :) You'd have to add an extra exception catcher and either repeat the refund block or wrap the exception as a future. Then I think it would semantically similar to the async-await code. |
Another nit is that if bank.decrement(cost) throws an exception thenAccept will never fire and the future returned by buyItem will never complete, might be a little more robust to use handle. |
Something like this? You can argue whether it looks ugly but I still think it's not that bad.
The text was updated successfully, but these errors were encountered: