This is a fix for http://jira.grails.org/browse/GRAILS-10977 including testcase
Fixes for GRAILS-10977
please could you submit the pull request against the 2.3.x branch, otherwise it will only go into the master branch (for 2.4)
I actually did the codechange on a 2.3.x branch and not master.
Closing this one, since it was merged to 2.3.x