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

Proxy unwrapping causes UndeclaredThrowableExceptions

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7.6, 1.7.7, 1.7.8
    • 2.0.0
    • None
    • None
    • MacOSX, Grails 1.3.7

    Description

      When upgrading to Grails 1.3.7, we started having trouble with UndeclaredThrowableExceptions popping out of our withTransaction blocks. Normally, throwing checked exceptions out of these blocks has worked perfectly well. We traced it down to Groovy 1.7.6's Git commit e53591b122bbfd039a03d37f2868ff95b5202c6b (http://svn.codehaus.org/groovy/branches/GROOVY_1_7_X@21327) which changes src/main/org/codehaus/groovy/runtime/ConversionHandler.java to unwrap GroovyRuntimeExceptions coming out of invokeCustom(). This takes what is normally an InvokerInvocationException containing our real checked exception - which would normally bounce all the way out to user code - and instead throws the real checked exception underneath, which promptly tries to propagate through a proxy which doesn't allow any checked exceptions through at all, and turns into an UndeclaredThrowableException.

      Immediate fix would be to revert the commit.

      2 sample apps attached (one is for Grails 1.3.6 [bundles Groovy 1.7.5], other is for Grails 1.3.7 [bundles Groovy 1.7.8], they are otherwise identical). Get a copy of Grails 1.3.6 and Grails 1.3.7.

      Extract the 1.3.6 app and type 'grails console'. Run:

      try {
      test.Test.withTransaction

      { throw new Exception("Testing throwing exceptions out of withTransaction") }
      } catch (Throwable t) {
      println t
      }

      Expected output:

      java.lang.Exception: Testing throwing exceptions out of withTransaction

      Now, switch to Grails 1.3.7, and run grails console for the 1.3.7 app. Same code:

      try {
      test.Test.withTransaction { throw new Exception("Testing throwing exceptions out of withTransaction") }

      } catch (Throwable t) {
      println t
      }

      Expected (undesirable) output:

      java.lang.reflect.UndeclaredThrowableException

      Attachments

        1. test-1.3.7.tar.gz
          156 kB
          John Stoneham
        2. test-1.3.6.tar.gz
          156 kB
          John Stoneham

        Activity

          People

            Unassigned Unassigned
            jstoneham John Stoneham
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: