grailsApplication.config annoyance

What would you expect the following to return if the property isn’t defined?

grailsApplication.config.unknownproperty

a. Returns null
b. Returns an empty string`
c. Throws an exception
d. None of the above

Answer: d. None of the above

In reality, the above situation returns an empty Groovy ConfigObject instance. If you want to know if the property exists you need to do something like:

if (grailsApplication.config.containsKey('unknownproperty')

Tagged with: ,
Posted in Programming
Design a site like this with WordPress.com
Get started