Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-4662

Closures leak InvokerInvocationException to Java callers

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.7.7
    • None
    • Compiler
    • None

    Description

      GroovyLib.groovy:

      class GroovyLib {
        void boom() throws IOException { throw new IOException() }
        void undeclaredBoom() { throw new IOException() }
        Closure closure = { throw new IOException() }
        Runnable runnable = { throw new IOException() }
      }
      

      GroovyJavaExceptionPropagationTest.java:

      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
        }
      }
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            pniederw Peter Niederwieser
            Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: