Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
1.7.6, 1.7.7, 1.7.8
-
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
} 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