The original test fails intermittently, the reproducer failed consistently. With the fix, the failure was not observed in the test or reproducer.
In jdk.internal.util.ReferencedKeyMap.entrySet() and toString() methods, avoid removing stale references that would modify the keyset while it is being iterated over. If GC removes the key, iterating or streaming over the keyset might get a ConcurrentModificationException. ------------- Commit messages: - 8336926: jdk/internal/util/ReferencedKeyTest.java can fail with ConcurrentModificationException Changes: https://git.openjdk.org/jdk/pull/20499/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=20499&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8336926 Stats: 11 lines in 1 file changed: 7 ins; 1 del; 3 mod Patch: https://git.openjdk.org/jdk/pull/20499.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/20499/head:pull/20499 PR: https://git.openjdk.org/jdk/pull/20499