RFR: 8336926: jdk/internal/util/ReferencedKeyTest.java can fail with ConcurrentModificationException

Aleksey Shipilev shade at openjdk.org
Thu Aug 8 09:25:31 UTC 2024


On Wed, 7 Aug 2024 19:26:59 GMT, Roger Riggs <rriggs at openjdk.org> wrote:

> 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.

Looks good. Comprehension check: only the methods that call back to `ReferencedKeyMap.get` are affected. So methods like `filterKeySet` itself are not affected, because they do `ReferenceKey::get`, not `ReferenceKeyMap::get`.

Wait a sec, I think this PR should include the un-problemlisting, e.g. reverting #20488?

-------------

Marked as reviewed by shade (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/20499#pullrequestreview-2227324243
Changes requested by shade (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/20499#pullrequestreview-2227326298


More information about the core-libs-dev mailing list