HubSpot / jinjava

Jinja template engine for Java
Apache License 2.0
701 stars 169 forks source link

Fix stackoverflow issue related to pymap hashcode computation #1111

Closed mattcoley closed 1 year ago

mattcoley commented 1 year ago

If a pymap contains itself we would get stackoverflow exceptions since the hashcode method recursively calls the hashcode method for all entrys in the set.

Instead we use an iterator so we can add additional elements from nested Maps. We then keep a HashSet with the System.identityHashCode() value so we can tell if we already visited a nested map.