You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/03/17 23:42:40 UTC

[GitHub] [kafka] jsancio commented on a change in pull request #10344: MINOR: Remove use of NoSuchElementException

jsancio commented on a change in pull request #10344:
URL: https://github.com/apache/kafka/pull/10344#discussion_r596455495



##########
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:
       `ConcurrentSkipListMap` has `lastEntry` and `firstEntry` that return `null` if the map is empty. `ConcurrentSkipListSet` only has `last` and `first` which throws if the set is empty. :dizzy: 




----------------------------------------------------------------
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:
users@infra.apache.org