When using a try-finally block in methods with return values then the finally block will not always be executed.
Here's a script which demonstrates the problem:
boolean foo () {
try {
println "try"
// only when next line is removed then the finally-block will be executed
if (0 == 1) return false
return true
}
finally {
println "finally"
}
}
foo ()
Output after starting: eddie@saringnb:~$ groovy test.groovy
try
Finally will only be executed when removing the line " if (0 == 1) return false".
I've reported a similar problem for Groovy 1.0 (http://jira.codehaus.org/browse/GROOVY-1663
), probably it was not solved completely.
BTW: Is there a planning for a bugfix release (e.g. 1.0.1) without new features which just removes these critical bugs? Would be important for production usage.
Thanks in advance,
Stefan