getMapValue throws exception

Post your questions and help other users.

Moderator: Martin

Post Reply
User avatar
kintrupf
Posts: 257
Joined: 10 Sep 2013 08:59

getMapValue throws exception

Post by kintrupf » 26 Jun 2014 12:54

The function "getMapValue(Map map, String key, Object default)" throws an exception when 'map' is null.
In my opinion the variant of the function with a default value should return that default value when the map does not exist.

More like treating a 'null' like an empty map instead of throwing an exception ;)
That would simplify some flows because no check is needed if the map variable actually exists.

Using "mapVar = addMapEntry(mapVar, 'key', value)" should also work without exception when mapVar is null or does not yet exist.

User avatar
Martin
Posts: 4468
Joined: 09 Nov 2012 14:23

Re: getMapValue throws exception

Post by Martin » 26 Jun 2014 16:13

I agree for the function "getMapValue(Map map, String key, Object default)" where the user is probably aware that map could be null.
"mapVar = addMapEntry(mapVar, 'key', value)" should create the map when it's null to make exactly this pattern possible so this is clearly a bug. This is fixed in the next build.

Post Reply