completable-futures
completable-futures copied to clipboard
Added unravel() to make it easier to work with CompletionExceptions
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.
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))
I think this PR is ready now.
It looks like Travis CI got stuck. Is there anyway to force it to run the checks again? Theoretically, this should be green.
I really hate to sound pushy, but is there any chance that this can be reviewed?
closing 3 years old PR. Feel free to re-open if you feel it's something that still could be useful