On Thu, 4 Jun 2026 02:52:31 GMT, Chen Liang <[email protected]> wrote:
> IteratorAtEnd spuriously failed for `WeakHashMap`. The underlying cause is > that with the migration of keys to `String` produced by concatenation, these > strings may be eagerly garbage collected, leaving the `WeakHashMap` and its > collection views empty, causing their `Iterator` to throw > `IllegalStateException` for a call to `remove()` because it never returned > any entry ever. > > The original failure could be reliably reproduced by adding a `System.gc()` > call right after the Map put for loop. I added an assert to prevent such > empty iterator to have a confusing error again, and made the keys strongly > referenced in a collection to avoid this immediate issue. > > --------- > - [x] I confirm that I make this contribution in accordance with the [OpenJDK > Interim AI Policy](https://openjdk.org/legal/ai). lgtm. ------------- Marked as reviewed by aboldtch (Committer). PR Review: https://git.openjdk.org/valhalla/pull/2509#pullrequestreview-4426045003
