I am using Grails 1.3.7 and I have similar code in multiple controllers:
def myAction = { MyCommand cmd ->
if (cmd.hasErrors()) {
// return bad request
} else {
someService.callSomeMethod(cmd.someId)
...
}
}
class MyCommand {
Long someId
static constraints = {
someId nullable: false
}
}
It works just fine 99.99% of the time. However, there are several cases where application logs indicate that the service was called with a null (i.e. cmd.someId returned null). However, that just does not make sense since the constraint is set to nullable: false
. It feels like that in those very rare cases grails forgot to call validate()
on the command object or the constraint was ignored.
Any hints for the cause of such problem would be appreciated.