David Jacot created KAFKA-15271: ----------------------------------- Summary: TimelineHashMap.entrySet yield unexpected results with nested TimelineHashMap Key: KAFKA-15271 URL: https://issues.apache.org/jira/browse/KAFKA-15271 Project: Kafka Issue Type: Bug Reporter: David Jacot
Example: {code:java} @Test public void bug() { SnapshotRegistry snapshotRegistry = new SnapshotRegistry(new LogContext()); // Topic -> Partition -> Offset TimelineHashMap<String, TimelineHashMap<Integer, Long>> offsets = new TimelineHashMap<>(snapshotRegistry, 0); snapshotRegistry.getOrCreateSnapshot(0); offsets .computeIfAbsent("foo", __ -> new TimelineHashMap<>(snapshotRegistry, 0)) .put(0, 100L); snapshotRegistry.getOrCreateSnapshot(1); offsets .computeIfAbsent("foo", __ -> new TimelineHashMap<>(snapshotRegistry, 0)) .put(1, 110L); snapshotRegistry.getOrCreateSnapshot(2); offsets .computeIfAbsent("foo", __ -> new TimelineHashMap<>(snapshotRegistry, 0)) .put(1, 111L); assertNull(offsets.get("foo", 1).get(1, 1)); offsets.entrySet(1).forEach(topicEntry -> { System.out.println(topicEntry.getKey()); topicEntry.getValue().entrySet(1).forEach(partitionEntry -> { System.out.println(partitionEntry.getKey() + " : " + partitionEntry.getValue()); }); }); /* The above code prints: foo 0 : 100 1 : 110 but should rather print: foo 0 : 100 */ } {code} It yields the expected result when the third put is removed. -- This message was sent by Atlassian Jira (v8.20.10#820010)