completable-futures icon indicating copy to clipboard operation
completable-futures copied to clipboard

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

Open npiguet opened this issue 4 years ago • 4 comments

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 avatar Nov 13 '20 11:11 npiguet

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 avatar Nov 17 '20 14:11 npiguet

I think this PR is ready now.

npiguet avatar Nov 23 '20 10:11 npiguet

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

npiguet avatar Nov 26 '20 18:11 npiguet

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

npiguet avatar Dec 17 '20 21:12 npiguet

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

caesar-ralf avatar Jul 05 '23 12:07 caesar-ralf