[ 
https://issues.apache.org/jira/browse/GROOVY-12764?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Paul King resolved GROOVY-12764.
--------------------------------
    Fix Version/s: 7.0.0-alpha-1
                   6.0.1
         Assignee: Paul King
       Resolution: Fixed

> AsyncScope close and defer fail with "Self-suppression not permitted" when 
> one exception instance is reported twice
> -------------------------------------------------------------------------------------------------------------------
>
>                 Key: GROOVY-12764
>                 URL: https://issues.apache.org/jira/browse/GROOVY-12764
>             Project: Groovy
>          Issue Type: Bug
>            Reporter: Paul King
>            Assignee: Paul King
>            Priority: Major
>             Fix For: 7.0.0-alpha-1, 6.0.1
>
>
> When two child tasks of an {{AsyncScope}}, or two {{defer}} actions, fail 
> with the same exception instance, the scope or async block throws 
> {{IllegalArgumentException: Self-suppression not permitted}} instead of that 
> exception. The real failure is lost. Checked and unchecked exceptions are 
> both affected.
> {code:groovy}
> import groovy.concurrent.AsyncScope
> def shared = new IllegalStateException('shared')
> // IllegalArgumentException: Self-suppression not permitted
> AsyncScope.withScope { scope ->
>     scope.async { throw shared }
>     scope.async { throw shared }
>     null
> }
> // IllegalArgumentException: Self-suppression not permitted
> await async {
>     defer { throw shared }
>     defer { throw shared }
>     1
> }
> {code}
> A realistic way to hit it: two children that await the same failed task each 
> rethrow its exception, so the scope sees one instance twice.
> Cause: {{DefaultAsyncScope.close()}} and {{AsyncSupport.executeDeferScope}} 
> add every later failure to the first one with {{addSuppressed}}, and 
> {{Throwable.addSuppressed}} rejects the exception itself. 
> {{AsyncScope.withScope}} already guards its body-versus-close case with an 
> identity check.
> Expected: the shared exception is thrown once, with nothing suppressed into 
> itself.
> Proposed fix: skip {{addSuppressed}} when the later failure is the same 
> instance as the first, at the three sites in {{close()}} and 
> {{executeDeferScope}}.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to