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
ConcurrentReferenceHashMap's entrySet violates the Map contract #27454
Comments
@jhoeller Thanks for the quick fix. I checked with Guava's tests and it looks like the other failures (like Map.contains) were resolved thanks to this and perhaps other fixes on 6.0-SNAPSHOT (I had only checked the last 5.x release). You might consider adding Guava's testlib dependency (their testing utilities, public static Test suite() {
var suite = MapTestSuiteBuilder
.using(new TestStringMapGenerator() {
@Override protected Map<String, String> create(Map.Entry<String, String>[] entries) {
var map = new LinkedCaseInsensitiveMap<String>();
for (var entry : entries) {
map.put(entry.getKey(), entry.getValue());
}
return map;
}
})
.named("LinkedCaseInsensitiveMap")
.withFeatures(
MapFeature.GENERAL_PURPOSE,
MapFeature.ALLOWS_NULL_VALUES,
CollectionFeature.SUPPORTS_ITERATOR_REMOVE,
CollectionSize.ANY);
return suite.createTestSuite();
}
<details> |
@ben-manes Thanks for raising this to begin with! Those violations remained completely unnoticed before, in particular the buggy equals comparison in the
I forgot to comment on |
A quick sanity test of this map using Guava's testlib found some simple violations. For example
entrySet().iterator()
does not throw an exception for the sequence [hasNext, hasNext, next, remove, remove]. In this caseIterator.remove()
failed to null out thelast
property after the first call, so a subsequent call does not throw anIllegalStateException
. As thekeySet
andvalues
views delegate toentrySet
, this error is found multiple times in Guava's suite. You might consider using this suite on other custom collections.Unit Tests
The text was updated successfully, but these errors were encountered: