paulk-asert opened a new pull request, #3298: URL: https://github.com/apache/groovy/pull/3298
Two async fixes for 6.0.1, one commit each. **GROOVY-12763: async constructs rethrow a checked exception as itself** `await` rethrew a checked exception unchanged, but five other paths wrapped it: - a scope child failure (`DefaultAsyncScope.close()`) and a `defer` action (`AsyncSupport.executeDeferScope`) in `RuntimeException` - a `withScope` body (including the timeout variant) and a generator body in `UndeclaredThrowableException`, added when the closure is converted to `Function` / `Consumer` - a `Flow.Publisher` error consumed with `for await` (`FlowPublisherAdapter`) in `RuntimeException` All five now rethrow the original exception, as `await` does (GROOVY-9381's exception-transparency principle; GROOVY-12459 for `for await`). Only the `UndeclaredThrowableException` layer that closure conversion adds around a checked exception is removed; other wrappers the code throws are kept. Suppressed exceptions from scope close are kept. - `AsyncSupport.rethrow` is now public and returns `RuntimeException` so call sites can write `throw rethrow(t)`; new `AsyncSupport.unwrapUndeclared` - `@apiNote` on `AsyncScope` and `close()` for Java callers, which can now receive a checked exception these methods don't declare - COMPATIBILITY.md entry for 6.0.1 - `testScopeCloseWithCheckedExceptionWrapped`, which asserted the old wrapping, becomes `testScopeCloseRethrowsCheckedExceptionUnwrapped` Known limitation: a checked exception the code itself wrapped in `UndeclaredThrowableException` and threw from a `withScope` or generator body is also unwrapped. Removing that needs entry points that avoid closure conversion (a `Closure` overload of `withScope`, a generator body type declaring `throws Throwable`), left for a later release. **GROOVY-12764: no "Self-suppression not permitted" when one exception instance is reported twice** Two children (for example, two that await the same failed task) or two `defer` actions failing with the same instance made `close()` / `executeDeferScope` throw `IllegalArgumentException` and lose the real failure. They now skip `addSuppressed` for the same instance, as `withScope` already does. **Tests** New tests in `AsyncAwaitTest` fail before the fix and pass after: each of the five paths, the two self-suppression cases, the paths under `@CompileStatic`, and wrapper preservation (a wrapper thrown by a child task or `defer` action is removed exactly as `await` removes it; one from a `Flow.Publisher` is kept). Locally: full `./gradlew test` (the one failure was a race in a new Flow test, since fixed), then `AsyncAwaitTest`, `groovy.concurrent.*` and `org.apache.groovy.runtime.async.*` green. Both commits are intended for `GROOVY_6_0_X` after CI passes here. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
