ijuma commented on a change in pull request #10344: URL: https://github.com/apache/kafka/pull/10344#discussion_r596895503
########## File path: core/src/main/scala/kafka/raft/KafkaMetadataLog.scala ########## @@ -37,8 +37,9 @@ final class KafkaMetadataLog private ( log: Log, scheduler: Scheduler, // This object needs to be thread-safe because it is used by the snapshotting thread to notify the - // polling thread when snapshots are created. - snapshotIds: ConcurrentSkipListSet[OffsetAndEpoch], + // polling thread when snapshots are created. Using a Map instead of a Set so that there is no + // need to handle NoSuchElementException. + snapshotIds: ConcurrentSkipListMap[OffsetAndEpoch, Unit], Review comment: @jsancio Iterators need to provide consistent behavior or they would not satisfy the Iterator contract. What I mean is: if `hasNext` returns `true`, then `next` has to return an element. It would not be ok for `next` to do something different in that case. So, it seems safe to use here. In any case, not a big deal to use `ConcurrentNavigableMap` since that's what `ConcurrentSkipListSet` uses too. But if we do that, I would suggest creating a simple wrapper that exposes the methods you want. ---------------------------------------------------------------- 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: us...@infra.apache.org