[
https://issues.apache.org/jira/browse/GROOVY-12763?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18144677#comment-18144677
]
ASF GitHub Bot commented on GROOVY-12763:
-----------------------------------------
codecov-commenter commented on PR #3298:
URL: https://github.com/apache/groovy/pull/3298#issuecomment-6869902146
##
[Codecov](https://app.codecov.io/gh/apache/groovy/pull/3298?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 `47.05882%` with `9 lines` in your changes missing
coverage. Please review.
:white_check_mark: Project coverage is 74.4958%. Comparing base
([`0b455da`](https://app.codecov.io/gh/apache/groovy/commit/0b455da1f570a2ecdf51620215396ba6f6460672?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache))
to head
([`d6edcaf`](https://app.codecov.io/gh/apache/groovy/commit/d6edcafb366cc8602c0ac1add23c5d1ff85080ed?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/3298?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/3298?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)
| 62.5000% | [2 Missing and 1 partial :warning:
](https://app.codecov.io/gh/apache/groovy/pull/3298?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
|
|
[...apache/groovy/runtime/async/DefaultAsyncScope.java](https://app.codecov.io/gh/apache/groovy/pull/3298?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fruntime%2Fasync%2FDefaultAsyncScope.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9ydW50aW1lL2FzeW5jL0RlZmF1bHRBc3luY1Njb3BlLmphdmE=)
| 25.0000% | [3 Missing :warning:
](https://app.codecov.io/gh/apache/groovy/pull/3298?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/AsyncScope.java](https://app.codecov.io/gh/apache/groovy/pull/3298?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fgroovy%2Fconcurrent%2FAsyncScope.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9ncm9vdnkvY29uY3VycmVudC9Bc3luY1Njb3BlLmphdmE=)
| 66.6667% | [1 Missing :warning:
](https://app.codecov.io/gh/apache/groovy/pull/3298?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
|
|
[...che/groovy/runtime/async/FlowPublisherAdapter.java](https://app.codecov.io/gh/apache/groovy/pull/3298?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fruntime%2Fasync%2FFlowPublisherAdapter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9ydW50aW1lL2FzeW5jL0Zsb3dQdWJsaXNoZXJBZGFwdGVyLmphdmE=)
| 0.0000% | [1 Missing :warning:
](https://app.codecov.io/gh/apache/groovy/pull/3298?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
|
|
[...g/apache/groovy/runtime/async/GeneratorBridge.java](https://app.codecov.io/gh/apache/groovy/pull/3298?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fruntime%2Fasync%2FGeneratorBridge.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9ydW50aW1lL2FzeW5jL0dlbmVyYXRvckJyaWRnZS5qYXZh)
| 0.0000% | [1 Missing :warning:
](https://app.codecov.io/gh/apache/groovy/pull/3298?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/3298?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)
```diff
@@ Coverage Diff @@
## master #3298 +/- ##
==================================================
+ Coverage 74.4894% 74.4958% +0.0064%
- Complexity 44906 44907 +1
==================================================
Files 1703 1703
Lines 152180 152179 -1
Branches 29166 29160 -6
==================================================
+ Hits 113358 113367 +9
+ Misses 28408 28405 -3
+ Partials 10414 10407 -7
```
| [Files with missing
lines](https://app.codecov.io/gh/apache/groovy/pull/3298?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/AsyncScope.java](https://app.codecov.io/gh/apache/groovy/pull/3298?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Fgroovy%2Fconcurrent%2FAsyncScope.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9ncm9vdnkvY29uY3VycmVudC9Bc3luY1Njb3BlLmphdmE=)
| `81.8182% <66.6667%> (+7.9051%)` | :arrow_up: |
|
[...che/groovy/runtime/async/FlowPublisherAdapter.java](https://app.codecov.io/gh/apache/groovy/pull/3298?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fruntime%2Fasync%2FFlowPublisherAdapter.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9ydW50aW1lL2FzeW5jL0Zsb3dQdWJsaXNoZXJBZGFwdGVyLmphdmE=)
| `68.4210% <0.0000%> (+0.3176%)` | :arrow_up: |
|
[...g/apache/groovy/runtime/async/GeneratorBridge.java](https://app.codecov.io/gh/apache/groovy/pull/3298?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fruntime%2Fasync%2FGeneratorBridge.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9ydW50aW1lL2FzeW5jL0dlbmVyYXRvckJyaWRnZS5qYXZh)
| `89.2857% <0.0000%> (+6.5271%)` | :arrow_up: |
|
[.../org/apache/groovy/runtime/async/AsyncSupport.java](https://app.codecov.io/gh/apache/groovy/pull/3298?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)
| `78.7879% <62.5000%> (+1.7692%)` | :arrow_up: |
|
[...apache/groovy/runtime/async/DefaultAsyncScope.java](https://app.codecov.io/gh/apache/groovy/pull/3298?src=pr&el=tree&filepath=src%2Fmain%2Fjava%2Forg%2Fapache%2Fgroovy%2Fruntime%2Fasync%2FDefaultAsyncScope.java&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3JjL21haW4vamF2YS9vcmcvYXBhY2hlL2dyb292eS9ydW50aW1lL2FzeW5jL0RlZmF1bHRBc3luY1Njb3BlLmphdmE=)
| `87.7863% <25.0000%> (-1.5267%)` | :arrow_down: |
... and [9 files with indirect coverage
changes](https://app.codecov.io/gh/apache/groovy/pull/3298/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>
> Async scopes, defer and generators wrap checked exceptions instead of
> rethrowing them as await does
> ---------------------------------------------------------------------------------------------------
>
> Key: GROOVY-12763
> URL: https://issues.apache.org/jira/browse/GROOVY-12763
> Project: Groovy
> Issue Type: Bug
> Reporter: Paul King
> Priority: Major
>
> {{await}} rethrows a checked exception from an async task unchanged, but five
> other async paths wrap it, so the caller sees a different exception from the
> one the code threw. Unchecked exceptions and {{Error}}s pass through
> unwrapped on every path.
> {code:groovy}
> import groovy.concurrent.*
> // rethrown as is: java.lang.Exception
> await async { throw new Exception('boom') }
> // java.lang.RuntimeException, cause java.lang.Exception
> AsyncScope.withScope { s -> s.async { throw new Exception('boom') }; null }
> // java.lang.reflect.UndeclaredThrowableException, cause java.lang.Exception
> AsyncScope.withScope { s -> throw new Exception('boom') }
> // java.lang.RuntimeException, cause java.lang.Exception
> await async { defer { throw new Exception('boom') }; 1 }
> // java.lang.reflect.UndeclaredThrowableException, cause java.lang.Exception
> def g = async { yield return 1; throw new Exception('boom') }
> for (x in g) {}
> {code}
> The five paths, as of 6.0.0:
> * *Scope child failure*: {{DefaultAsyncScope.close()}} wraps a checked
> failure in {{RuntimeException}}. Its javadoc says "the first failure is
> rethrown".
> * *{{withScope}} body*: the Closure is coerced to {{Function}}, which wraps a
> checked exception in {{UndeclaredThrowableException}}. The same applies to
> {{withScope}} with a timeout.
> * *{{defer}} action*: {{AsyncSupport.executeDeferScope}} wraps it in
> {{RuntimeException}}.
> * *Generator body*: the Closure-to-{{Consumer}} coercion wraps it in
> {{UndeclaredThrowableException}} ({{GeneratorBridge}}).
> * *{{Flow.Publisher}} consumed with {{for await}}*: an {{onError}} carrying a
> checked exception is rethrown as {{RuntimeException}}
> ({{FlowPublisherAdapter}}).
> Expected: the original exception in all five cases, as with {{await}}.
> GROOVY-9381 lists exception transparency as a design principle ("callers see
> the same exceptions they would in synchronous code"), and GROOVY-12459 made a
> failing {{for await}} producer surface its checked exception rather than a
> wrapper. Kotlin's {{coroutineScope}} and C#'s {{await}} also rethrow the
> original exception.
> Proposed fix:
> * Rethrow the original exception at the three {{RuntimeException}} wrap sites.
> * In {{withScope}} and the generator, remove an
> {{UndeclaredThrowableException}} only when its cause is a checked exception,
> which is the layer the closure coercion adds. An
> {{UndeclaredThrowableException}} around an unchecked exception, or another
> wrapper the code itself threw, is kept.
> * Suppressed exceptions from scope close are kept.
> * Add an {{@apiNote}} to {{AsyncScope}} and {{close()}}: both declare no
> checked exceptions but can now throw one, so Java callers catch {{Exception}}
> and test its type.
> A wrapper that a child task or {{defer}} action throws itself, such as
> {{ExecutionException}}, is removed as {{await}} removes it. On 6.0.0 the
> extra {{RuntimeException}} happened to hide that. Whether {{await}} should
> remove only the layers the runtime added is left for a separate discussion.
> Compatibility: code that catches {{RuntimeException}} or
> {{UndeclaredThrowableException}} around these calls and then reads
> {{getCause()}} will now receive the checked exception directly.
> {{AsyncAwaitTest.testScopeCloseWithCheckedExceptionWrapped}} asserted the old
> wrapping and changes with the fix. This needs a release note.
> Known limitation: a checked exception that the code itself wrapped in an
> {{UndeclaredThrowableException}} and threw from a {{withScope}} or generator
> body is also unwrapped, because it can't be told apart from the coercion
> layer. Removing that limitation needs new entry points that avoid closure
> coercion (a generator body type declaring {{throws Throwable}}, and a
> {{Closure}} overload of {{withScope}}); that is left for a later release.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)