Skip to content

Conversation

natemort
Copy link
Member

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 cadence-workflow:master Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

3 participants