[
https://issues.apache.org/jira/browse/GROOVY-12788?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18153977#comment-18153977
]
ASF GitHub Bot commented on GROOVY-12788:
-----------------------------------------
jaragunde commented on PR #3380:
URL: https://github.com/apache/groovy/pull/3380#issuecomment-7344200509
> ## 🚨 TestLens detected 3 failed tests 🚨
> ...
> ### Test Failures
> **GrabResolverTest > testResolverDefinitionResolvesDependency()** (:test
in [Build and test / lts (25,
ubuntu-latest)](https://github.com/apache/groovy/actions/runs/46406341095/job/141805569199?pr=3380))
>
> **GrabResolverTest >
testResolverDefinitionResolvesDependencyWithShorthand()** (:test in [Build and
test / lts (25,
ubuntu-latest)](https://github.com/apache/groovy/actions/runs/46406341095/job/141805569199?pr=3380))
>
> **RegressionTest > testGroovy12788()** (:test in [Build and test / lts
(25,
ubuntu-latest)](https://github.com/apache/groovy/actions/runs/46406341095/job/141805569199?pr=3380))
>
`testGroovy12788` is now passing, the other two fail in one of the jobs, but
I think it's unrelated to this patch? It was also failing in other PRs at the
time I submitted.
> Awaitable.all() and await(a, b) do not fail fast as documented
> --------------------------------------------------------------
>
> Key: GROOVY-12788
> URL: https://issues.apache.org/jira/browse/GROOVY-12788
> Project: Groovy
> Issue Type: Bug
> Components: groovy-runtime
> Affects Versions: 6.0.0
> Reporter: Stephen Albrecht
> Priority: Major
>
> Environment: Groovy 6.0.0, JDK 25.0.1
> The
> [JavaDoc|https://github.com/apache/groovy/blob/bc6b3cfd9f8f3397129f8ebbdf85a189d16d7360/src/main/java/groovy/concurrent/Awaitable.java#L402-L404]
> for Awaitable.all() states "Like JavaScript's Promise.all(), the combined
> awaitable fails as soon as the first source fails."
> However, Awaitable.all() waits for every source to complete before failing.
> The implementation inÂ
> [AwaitCombinators.allAsync|https://github.com/apache/groovy/blob/bc6b3cfd9f8f3397129f8ebbdf85a189d16d7360/src/main/java/org/apache/groovy/runtime/async/AwaitCombinators.java#L84-L85]
> is built on CompletableFuture.allOf(), whose JavaDoc states "Returns a new
> CompletableFuture that is completed when all of the given CompletableFutures
> complete. If any of the given CompletableFutures complete exceptionally, then
> the returned CompletableFuture also does so". allOf() therefore isn't
> fail-fast.
> await(a, b) is affected too.
> {code:java}
> import groovy.concurrent.Awaitable
> def time = { String label, Closure body ->
> Â Â def start = System.currentTimeMillis()
> Â Â try {
> Â Â Â Â body()
> Â Â } catch (e) {
> Â Â Â Â println "$label threw after ${System.currentTimeMillis() - start}ms"
> Â Â }
> }
> time('Awaitable.all') {
> Â Â await Awaitable.all(
> Â Â Â Â async { Thread.sleep(3000) },
> Â Â Â Â async { throw new RuntimeException('fail') }
> Â Â )
> }
> time('await(a, b)') {
> Â Â await(
> Â Â Â Â async { Thread.sleep(3000) },
> Â Â Â Â async { throw new RuntimeException('fail') }
> Â Â )
> }
> {code}
> {code:java}
> Awaitable.all threw after 3005ms
> await(a, b) threw after 3004ms{code}
> Expected: both throw after ~0ms (the second source fails immediately)
> Actual: both throw after 3000ms (once the first source completes)
> allAsync() already [hooks a callback onto every source that runs on
> failure|https://github.com/apache/groovy/blob/bc6b3cfd9f8f3397129f8ebbdf85a189d16d7360/src/main/java/org/apache/groovy/runtime/async/AwaitCombinators.java#L79],
> so it can probably just return the failure immediately with
> result.completeExceptionally(asCompletionException(error)) and keep
> CompletableFuture.allOf() for the success case.
> This would match the Promise.all() behavior which doesn't cancel the
> remaining sources.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)