spotify / completable-futures

Utilities for working with futures in Java 8
Apache License 2.0
393 stars 51 forks source link

Added unravel() to make it easier to work with CompletionExceptions #80

Closed npiguet closed 1 year ago

npiguet commented 3 years ago

I often have to add this annoying boilerplate code to unwrap CompletionExceptions (potentially multiple layers of them, or sometimes none at all), so I thought this might be a useful addition to this library.

This is a draft PR with missing comments and tests, just to see if people are interested, and to see if it is worth the effort of writing the missing bits.

See the changes to README.md for use cases.

npiguet commented 3 years ago

I've added unravel(Callable), which can be nicely combined with join() and get() using method references. I've tried making special utility methods, but there was a lot of overloads (join, get, get(long, TimeUnit), getNow, etc...). It looks cleaner to me that way.

the most common use cases would be unravel(future::join), unravel(future::get), or (slightly uglier but still acceptable IMO) unravel(() -> future.get(2, SECONDS))

npiguet commented 3 years ago

I think this PR is ready now.

npiguet commented 3 years ago

It looks like Travis CI got stuck. Is there anyway to force it to run the checks again? Theoretically, this should be green.

npiguet commented 3 years ago

I really hate to sound pushy, but is there any chance that this can be reviewed?

caesar-ralf commented 1 year ago

closing 3 years old PR. Feel free to re-open if you feel it's something that still could be useful