GRAILS-9106 re-applied the changes from the 2.1 branch