I hate it. I simply hate it.
If a Grails parameter is null and you call toString()
on it, it doesn't fail with a good old NullPointerException
like I expected. Instead, what you get is a String with value 'null'.
The only way to get a null value when the param is null, is to use the Groovy Safe Navigation operator.
Therefore:
given:
params.some = null
when:
controller.index()
then:
notThrown NullPointerException
params.some.toString() == 'null'
params.some?.toString() == null