MapDotKeyReplacer throws an ConcurrentModificationException
See original GitHub issueMapKeyDotReplacer 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;
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Why is a ConcurrentModificationException thrown and how to ...
This will throw a ConcurrentModificationException when the it.hasNext() is called the second time. The correct approach would be. Iterator it = ...
Read more >java.util.ConcurrentModificationException - DigitalOcean
From the output stack trace, it's clear that the concurrent modification exception is thrown when we call iterator next() function.
Read more >How to Avoid the Concurrent Modification Exception in Java
The ConcurrentModificationException in Java occurs when an object is attempted to be modified concurrently without permission.
Read more >Fix the ConcurrentModificationException | TechTarget
Java's ConcurrentModificationException is thrown when a collection is modified while a Java Iterator is trying to loop through it.
Read more >Avoiding the ConcurrentModificationException in Java
@Test(expected = ConcurrentModificationException.class) public void whilstRemovingDuringIteration_shouldThrowException() throws ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

fix is released in 5.8.5 @luca010 thanks for your contribution, well done
ok, please create the pull request from your fork to javers master