[
https://issues.apache.org/jira/browse/GROOVY-4662?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18149086#comment-18149086
]
Daniel Sun commented on GROOVY-4662:
------------------------------------
Fixed on master; added a regression test in
bc7b4a42bac56eaab63721f3e3f2480ef70b83ee
(https://github.com/apache/groovy/commit/bc7b4a42bac56eaab63721f3e3f2480ef70b83ee).
> Closures leak InvokerInvocationException to Java callers
> --------------------------------------------------------
>
> Key: GROOVY-4662
> URL: https://issues.apache.org/jira/browse/GROOVY-4662
> Project: Groovy
> Issue Type: Bug
> Components: Compiler
> Affects Versions: 1.7.7
> Reporter: Peter Niederwieser
> Assignee: Daniel Sun
> Priority: Major
> Fix For: 7.0.0-alpha-1
>
>
> GroovyLib.groovy:
> {code}
> class GroovyLib {
> void boom() throws IOException { throw new IOException() }
> void undeclaredBoom() { throw new IOException() }
> Closure closure = { throw new IOException() }
> Runnable runnable = { throw new IOException() }
> }
> {code}
> GroovyJavaExceptionPropagationTest.java:
> {code}
> public class GroovyJavaExceptionPropagationTest {
> @Test(expected = IOException.class)
> public void callGroovyMethodThatThrowsDeclaredCheckedException() throws
> Exception {
> new GroovyLib().boom(); // throws IOException
> }
> @Test(expected = IOException.class)
> public void callGroovyMethodThatThrowsUndeclaredCheckedException() throws
> Exception {
> new GroovyLib().undeclaredBoom(); // throws IOException
> }
> @Test(expected = IOException.class)
> public void callGroovyClosureThatThrowsCheckedException() throws Exception {
> new GroovyLib().getClosure().call(); // throws InvokerInvocationException
> }
> @Test(expected = IOException.class)
> public void
> callGroovyClosureDisguisedAsRunnableThatThrowsCheckedException() throws
> Exception {
> new GroovyLib().getRunnable().run(); // throws InvokerInvocationException
> }
> }
> {code}
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)