Skip to content

MapDotKeyReplacer throws an ConcurrentModificationException #910

Closed
@luca010

Description

@luca010

MapKeyDotReplacer throws an ConcurrentModificationException when tries to replace dots in the document Map. I would suggest to rewrite the method replaceInMapKeys in the MapKeyDotReplacer class as follows:

private Document replaceInMapKeys(Document map, String regexFrom, String from, String to) {
    Document result = new Document();
    for (String key : map.keySet()) {
        Object val = map.get(key);
        if (key.contains(from)) {
            String escaped = key.replaceAll(regexFrom, to);
            result.put(escaped, val);
        } else {
           result.put(key, val);
        }
    }
    return result;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions