i want to iterate through a hash checking for keys and variations of keys. for example:
<#list myhash?keys as key>
<#if myhash[key] == 'foo'>
<#elseif myhash[key + 'variation'] == 'bar'>
do something else
if key + 'variation' doesn't exist in myhash, then SimpleHash will do a put (SimpleHash line 204), which will cause a ConcurrentModificationException on the next iteration because the hash has been modified.
the reason for the put seems to be to cache the value wrapped in a TemplateModel. i'm sure this is a good thing for performance reasons, but it obviously has its side effects.
the solution is to not add a new entry to the hash. if you are just replacing the value for a particular key with a new value, then you won't trigger a ConcurrentModificationException. but if the key isn't in the hash, then you shouldn't add it.
so after line 202, add this:
if (result == null) return tm;