Skip to content
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

Fix Promise#allOf(Promise<?>...) #881

Merged
merged 3 commits into from
Apr 19, 2024
Merged

Fix Promise#allOf(Promise<?>...) #881

merged 3 commits into from
Apr 19, 2024

Conversation

natemort
Copy link
Contributor

AllOfFuture completes with the list of values from each promise passed into its constructor. The varargs variant of Promise#allOf however has a return type of Void, so the intention seems to be to discard the results of the promises. Because a list of results is disjoint from Void any invocation of this method will throw an exception when the promises complete as we attempt to cast ArrayList to Void.

To resolve this we explicitly discard the result of the promises by mapping the result to null, the only possible value of Void.

What changed?
Change the behavior of Promise#allOf(Promise<?>...) to no longer throw an exception.

Why?
Allows for using Promise#allOf without wrapping the arguments in a collection first.

How did you test it?
Unit tests.

Potential risks
None

Release notes

Documentation Changes

AllOfFuture completes with the list of values from each promise passed into its constructor. The varargs variant of Promise#allOf however has a return type of Void, so the intention seems to be to discard the results of the promises. Because a list of results is disjoint from Void any invocation of this method will throw an exception when the promises complete.

To resolve this we explicitly discard the result of the promises by mapping the result to null, the only possible value of Void.
@coveralls
Copy link

coveralls commented Apr 18, 2024

Pull Request Test Coverage Report for Build 2258

Details

  • 1 of 1 (100.0%) changed or added relevant line in 1 file are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+0.01%) to 60.297%

Files with Coverage Reduction New Missed Lines %
src/main/java/com/uber/cadence/internal/sync/WorkflowThreadContext.java 1 82.46%
Totals Coverage Status
Change from base Build 2251: 0.01%
Covered Lines: 11457
Relevant Lines: 19001

💛 - Coveralls

@natemort natemort merged commit 88a8a78 into uber:master Apr 19, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants