-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Avoid completableFuture.asScala crash for MinimalStage #10615
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
Conversation
I will fix it in other repo this weekend |
I was missed this @DougLea |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Thanks for the opportunity to read up on these interfaces I'd managed to avoid all these years. The issue is exactly this concluding line of JavaDoc:
That is obscure, but says don't call The other "object lesson" (pun alert) is why did we ever think it's OK to downcast to runtime types? On the one hand, we can despise Java's penchant for implementing an interface by throwing unsupported operations, such as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Despite the hiccup, it was pleasant to see the previous optimization and the benchmarking.
My last question is why do we downcast at all if I can always call CompletionStage#toCompetableFuture#isDone
? Any completion stage can tell me (via the "common conversion type") whether a value is available.
Since it's only an optimization of sorts, approving forthwith.
Maybe |
CompletableFuture.completedStage
creates aMinimalStage
instance which extendsCompletableFuture
and overrides most methods withUnsupportedOperationException
.Calling
toCompletableFuture
on it creates a freshCompletableFuture
.Fixes scala/bug#12918.