fix for GRAILS-11396 "Using g.img causes StackOverflowException"