Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add testlib case for HashMap untreeifying during iteration #2897

Open
ben-manes opened this issue Aug 7, 2017 · 4 comments
Open

Add testlib case for HashMap untreeifying during iteration #2897

ben-manes opened this issue Aug 7, 2017 · 4 comments
Assignees
Labels
P3 package=collect type=enhancement Make an existing feature better

Comments

@ben-manes
Copy link
Contributor

A really interesting edge case for HashMap was reported due to my usage, see ben-manes/caffeine#176.

It seems that when the entrySet iterator removes entries, the untreeifying causes the entries to be rewritten. Then the entries returned by the iterator are stale and setValue has no effect on the HashMap. This is because unlike concurrent maps, the setValue does not perform a map.put(key, value) to handle the race.

I believe this is a JDK bug and we are awaiting feedback. Guava's testlib doesn't assert this case, so it might be a good addition.

@ben-manes
Copy link
Contributor Author

@kluever
Copy link
Member

kluever commented Aug 15, 2017

Sounds like something @lowasser might be interested in taking a look at.

@ronshapiro ronshapiro added type=enhancement Make an existing feature better P3 labels Aug 8, 2019
@jbduncan
Copy link
Contributor

@ben-manes The way I see it, it's still worth keeping this open since it seems to be interesting edge case worth testing against, at least for custom Map impls like ImmutableMap.

@ben-manes
Copy link
Contributor Author

Sure thing. JDK bug was fixed, fwiw.

@ben-manes ben-manes reopened this Feb 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P3 package=collect type=enhancement Make an existing feature better
Projects
None yet
Development

No branches or pull requests

6 participants