cats-effect
cats-effect copied to clipboard
Add `Async#fromJavaFuture`
~~Still needs some tests.~~ /cc @Daenyth
I'm a little on the fence about this one. IMO if we're going to do it, we should at least double-check to see if the Future is secretly a CompletableFuture, to avoid creating a foot gun.
Oh, I missed the fact that CompletableFuture extends Future. Fair point.
For the record I'm skeptical about this one too now. Somebody asked on the Discord about just Future and the cancellation logic doesn't come for free so it seemed worth adding.
More thoughts from Daniel:
second, it makes it seem like it's fine to convert from Future to IO, in the same way that it is with CF when really it's not this in turn may lead users to select APIs which return Future rather than CF since they seem equivalent basically the argument is that putting something in the API elevates the case to something more "supported" and "okay" but really it's not okay. it's terrible. sometimes you have to do it, but not often
So that seems like a convincing argument not to add this. The workaround is to do IO.blocking(future.get()) or inline what I have here if you want cancelation.