afs commented on issue #637: JENA-1784 CacheSimple doesn't check keys for equality URL: https://github.com/apache/jena/pull/637#issuecomment-558737355 Thank you - I agree with the fix. Writing the test is harder! :-) Rather than rely on the interesting fact that `hash("Aa") == hash("BB")`, which is implementation dependent (it's true in OpenJDK at the moment), how about creating objects with the explicit features needed? Object obj1 = new Object() { @Override public int hashCode() { return 1; } }; Object obj2 = new Object() { @Override public int hashCode() { return 1; } }; assertEquals(obj1.hashCode(), obj2.hashCode()); assertNotEquals(obj1, obj2); Cache<Object, Integer> cache = new CacheSimple<>(10); cache.put(obj1, 1); assertTrue("Same key, expected in cache", cache.containsKey(obj1)); assertFalse("Keys with same hash code should not be considered equal", cache.containsKey(obj2));
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
