[
https://issues.apache.org/jira/browse/GROOVY-9381?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18061973#comment-18061973
] ASF GitHub Bot commented on GROOVY-9381: ---------------------------------------- codecov-commenter commented on PR #2387: URL: https://github.com/apache/groovy/pull/2387#issuecomment-3980677262 ## [Codecov](https://app.codecov.io/gh/apache/groovy/pull/2387?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report :x: Patch coverage is `78.87789%` with `128 lines` in your changes missing coverage. Please review. :white_check_mark: Project coverage is 66.8359%. Comparing base ([`a0feded`](https://app.codecov.io/gh/apache/groovy/commit/a0fededff8f07da2ddcb3977539d1208930fc5f6?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`e9a0265`](https://app.codecov.io/gh/apache/groovy/commit/e9a02650d3b34c7d863ac64b89a8b9bf180f4696?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)). :warning: Report is 1 commits behind head on master. | [Files with missing lines](https://app.codecov.io/gh/apache/groovy/pull/2387?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines | |---|---|---| | [.../org/apache/groovy/runtime/async/AsyncSupport.java](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fruntime%2Fasync%2FAsyncSupport.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9ydW50aW1lL2FzeW5jL0FzeW5jU3VwcG9ydC5qYXZh) | 73.4807% | [35 Missing and 13 partials :warning: ](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | | [...va/groovy/concurrent/AwaitableAdapterRegistry.java](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fgroovy%2Fconcurrent%2FAwaitableAdapterRegistry.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9ncm9vdnkvY29uY3VycmVudC9Bd2FpdGFibGVBZGFwdGVyUmVnaXN0cnkuamF2YQ==) | 69.4444% | [26 Missing and 7 partials :warning: ](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | | [...ehaus/groovy/transform/AsyncASTTransformation.java](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2FAsyncASTTransformation.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS9Bc3luY0FTVFRyYW5zZm9ybWF0aW9uLmphdmE=) | 79.7980% | [10 Missing and 10 partials :warning: ](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | | [...che/groovy/runtime/async/AsyncStreamGenerator.java](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fruntime%2Fasync%2FAsyncStreamGenerator.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9ydW50aW1lL2FzeW5jL0FzeW5jU3RyZWFtR2VuZXJhdG9yLmphdmE=) | 60.0000% | [13 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | | [...odehaus/groovy/transform/AsyncTransformHelper.java](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2FAsyncTransformHelper.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS9Bc3luY1RyYW5zZm9ybUhlbHBlci5qYXZh) | 90.3846% | [0 Missing and 5 partials :warning: ](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | | [src/main/java/groovy/concurrent/AsyncUtils.java](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fgroovy%2Fconcurrent%2FAsyncUtils.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9ncm9vdnkvY29uY3VycmVudC9Bc3luY1V0aWxzLmphdmE=) | 78.9474% | [4 Missing :warning: ](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | | [src/main/java/groovy/concurrent/AsyncStream.java](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fgroovy%2Fconcurrent%2FAsyncStream.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9ncm9vdnkvY29uY3VycmVudC9Bc3luY1N0cmVhbS5qYXZh) | 75.0000% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | | [.../main/java/groovy/concurrent/AwaitableAdapter.java](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fgroovy%2Fconcurrent%2FAwaitableAdapter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9ncm9vdnkvY29uY3VycmVudC9Bd2FpdGFibGVBZGFwdGVyLmphdmE=) | 50.0000% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | | [...va/org/apache/groovy/parser/antlr4/AstBuilder.java](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fparser%2Fantlr4%2FAstBuilder.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9wYXJzZXIvYW50bHI0L0FzdEJ1aWxkZXIuamF2YQ==) | 98.4127% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | | [...org/apache/groovy/runtime/async/GroovyPromise.java](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fruntime%2Fasync%2FGroovyPromise.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9ydW50aW1lL2FzeW5jL0dyb292eVByb21pc2UuamF2YQ==) | 95.6522% | [0 Missing and 1 partial :warning: ](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | <details><summary>Additional details and impacted files</summary> [](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) ```diff @@ Coverage Diff @@ ## master #2387 +/- ## ================================================== + Coverage 66.7519% 66.8359% +0.0840% - Complexity 29846 30027 +181 ================================================== Files 1382 1393 +11 Lines 116130 116801 +671 Branches 20475 20603 +128 ================================================== + Hits 77519 78065 +546 - Misses 32278 32367 +89 - Partials 6333 6369 +36 ``` | [Files with missing lines](https://app.codecov.io/gh/apache/groovy/pull/2387?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | | |---|---|---| | [src/main/java/groovy/concurrent/AwaitResult.java](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fgroovy%2Fconcurrent%2FAwaitResult.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9ncm9vdnkvY29uY3VycmVudC9Bd2FpdFJlc3VsdC5qYXZh) | `100.0000% <100.0000%> (ø)` | | | [src/main/java/groovy/concurrent/Awaitable.java](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fgroovy%2Fconcurrent%2FAwaitable.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9ncm9vdnkvY29uY3VycmVudC9Bd2FpdGFibGUuamF2YQ==) | `100.0000% <100.0000%> (ø)` | | | [...ain/java/org/codehaus/groovy/ast/ModifierNode.java](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Fast%2FModifierNode.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L2FzdC9Nb2RpZmllck5vZGUuamF2YQ==) | `77.7778% <100.0000%> (+0.4193%)` | :arrow_up: | | [src/main/java/groovy/concurrent/AsyncStream.java](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fgroovy%2Fconcurrent%2FAsyncStream.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9ncm9vdnkvY29uY3VycmVudC9Bc3luY1N0cmVhbS5qYXZh) | `75.0000% <75.0000%> (ø)` | | | [.../main/java/groovy/concurrent/AwaitableAdapter.java](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fgroovy%2Fconcurrent%2FAwaitableAdapter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9ncm9vdnkvY29uY3VycmVudC9Bd2FpdGFibGVBZGFwdGVyLmphdmE=) | `50.0000% <50.0000%> (ø)` | | | [...va/org/apache/groovy/parser/antlr4/AstBuilder.java](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fparser%2Fantlr4%2FAstBuilder.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9wYXJzZXIvYW50bHI0L0FzdEJ1aWxkZXIuamF2YQ==) | `86.7924% <98.4127%> (+0.3304%)` | :arrow_up: | | [...org/apache/groovy/runtime/async/GroovyPromise.java](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fruntime%2Fasync%2FGroovyPromise.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9ydW50aW1lL2FzeW5jL0dyb292eVByb21pc2UuamF2YQ==) | `95.6522% <95.6522%> (ø)` | | | [src/main/java/groovy/concurrent/AsyncUtils.java](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fgroovy%2Fconcurrent%2FAsyncUtils.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9ncm9vdnkvY29uY3VycmVudC9Bc3luY1V0aWxzLmphdmE=) | `78.9474% <78.9474%> (ø)` | | | [...odehaus/groovy/transform/AsyncTransformHelper.java](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fcodehaus%2Fgroovy%2Ftransform%2FAsyncTransformHelper.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvY29kZWhhdXMvZ3Jvb3Z5L3RyYW5zZm9ybS9Bc3luY1RyYW5zZm9ybUhlbHBlci5qYXZh) | `90.3846% <90.3846%> (ø)` | | | [...che/groovy/runtime/async/AsyncStreamGenerator.java](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fruntime%2Fasync%2FAsyncStreamGenerator.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9ydW50aW1lL2FzeW5jL0FzeW5jU3RyZWFtR2VuZXJhdG9yLmphdmE=) | `60.0000% <60.0000%> (ø)` | | | ... and [3 more](https://app.codecov.io/gh/apache/groovy/pull/2387?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | | ... and [6 files with indirect coverage changes](https://app.codecov.io/gh/apache/groovy/pull/2387/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) </details> <details><summary> :rocket: New features to boost your workflow: </summary> - :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems. - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges. </details> > Support async/await like ES7 > ---------------------------- > > Key: GROOVY-9381 > URL: https://issues.apache.org/jira/browse/GROOVY-9381 > Project: Groovy > Issue Type: New Feature > Reporter: Daniel Sun > Priority: Major > > Here is an example to show proposed syntax and backend API(Java's > {{CompletableFuture}} or GPars's {{{}Promise{}}}), but I think it's better > for Groovy to have its own {{Promise}} to decouple with Java API because > async/await as a language feature should be as stable as possible. > {{async}} will generate the {{Awaitable}} instance such as Groovy {{Promise}} > implementing the {{Awaitable}} interface, and {{await}} can wait for any > {{Awaitable}} instance to complete and unwrap it for the result. > {code:java} > /** > * 1. An async function that simulates a network API call. > * The 'async' keyword implies it runs asynchronously without blocking. > */ > async fetchUserData(userId) { > println "Starting to fetch data for user ${userId}..." > > // Simulate a 1-second network delay. > Thread.sleep(1000) > > println "Fetch successful!" > // The 'async' function implicitly returns a "CompletableFuture" or > "Promise" containing this value. > return [userId: userId, name: 'Daniel'] > } > /** > * 2. An async function that uses 'await' to consume the result. > */ > async processUserData() { > println "Process started, preparing to fetch user data..." > > try { > // 'await' pauses this function until fetchUserData completes > // and returns the final result directly. > def user = await fetchUserData(1) > > println "Data received: ${user}" > return "Processing complete for ${user.name}." > > } catch (Exception e) { > return "An error occurred: ${e.message}" > } > } > // --- Execution --- > println "Script starting..." > // Kick off the entire asynchronous process. > def future = processUserData() > // This line executes immediately, proving the process is non-blocking. > println "Script continues to run while user data is being fetched in the > background..." > def result = future.get() > println "Script finished: ${result}" > {code} > Use async/await with closure or lambda expression: > {code} > // use closure > def c = async { > println "Process started, preparing to fetch user data..." > > try { > // 'await' pauses this function until fetchUserData completes > // and returns the final result directly. > def user = await fetchUserData(1) > > println "Data received: ${user}" > return "Processing complete for ${user.name}." > > } catch (Exception e) { > return "An error occurred: ${e.message}" > } > } > def future = c() > {code} > {code} > // use lambda expression > def c = async () -> { > println "Process started, preparing to fetch user data..." > > try { > // 'await' pauses this function until fetchUserData completes > // and returns the final result directly. > def user = await fetchUserData(1) > > println "Data received: ${user}" > return "Processing complete for ${user.name}." > > } catch (Exception e) { > return "An error occurred: ${e.message}" > } > } > def future = c() > {code} -- This message was sent by Atlassian Jira (v8.20.10#820010)
