showuon commented on a change in pull request #9178: URL: https://github.com/apache/kafka/pull/9178#discussion_r486747159
########## File path: core/src/main/scala/kafka/log/LogCleanerManager.scala ########## @@ -355,22 +355,28 @@ private[log] class LogCleanerManager(val logDirs: Seq[File], } /** - * Update checkpoint file, or removing topics and partitions that no longer exist + * Update checkpoint file, or remove topics and partitions that no longer exist * * @param dataDir The File object to be updated * @param update The [TopicPartition, Long] map data to be updated. pass "none" if doing remove, not add * @param topicPartitionToBeRemoved The TopicPartition to be removed */ - def updateCheckpoints(dataDir: File, update: Option[(TopicPartition, Long)], topicPartitionToBeRemoved: TopicPartition = null): Unit = { + def updateCheckpoints(dataDir: File, update: Option[(TopicPartition, Long)], topicPartitionToBeRemoved: Option[TopicPartition] = None): Unit = { inLock(lock) { val checkpoint = checkpoints(dataDir) if (checkpoint != null) { try { val existing = update match { case Some(updatedOffset) => - checkpoint.read().filter { case (tp, _) => logs.keys.contains(tp) }.toMap ++ update + checkpoint.read().filter { case (tp, _) => logs.keys.contains(tp) }.toMap + updatedOffset case None => - checkpoint.read().filter { case (tp, _) => logs.keys.contains(tp) }.toMap - topicPartitionToBeRemoved + topicPartitionToBeRemoved match { Review comment: Good suggestion! Updated. ########## File path: core/src/main/scala/kafka/log/LogCleanerManager.scala ########## @@ -355,22 +355,28 @@ private[log] class LogCleanerManager(val logDirs: Seq[File], } /** - * Update checkpoint file, or removing topics and partitions that no longer exist + * Update checkpoint file, or remove topics and partitions that no longer exist * * @param dataDir The File object to be updated * @param update The [TopicPartition, Long] map data to be updated. pass "none" if doing remove, not add * @param topicPartitionToBeRemoved The TopicPartition to be removed */ - def updateCheckpoints(dataDir: File, update: Option[(TopicPartition, Long)], topicPartitionToBeRemoved: TopicPartition = null): Unit = { + def updateCheckpoints(dataDir: File, update: Option[(TopicPartition, Long)], topicPartitionToBeRemoved: Option[TopicPartition] = None): Unit = { inLock(lock) { val checkpoint = checkpoints(dataDir) if (checkpoint != null) { try { val existing = update match { case Some(updatedOffset) => - checkpoint.read().filter { case (tp, _) => logs.keys.contains(tp) }.toMap ++ update + checkpoint.read().filter { case (tp, _) => logs.keys.contains(tp) }.toMap + updatedOffset case None => - checkpoint.read().filter { case (tp, _) => logs.keys.contains(tp) }.toMap - topicPartitionToBeRemoved + topicPartitionToBeRemoved match { + case Some(topicPartion) => + checkpoint.read().filter { case (tp, _) => logs.keys.contains(tp) }.toMap - topicPartion + case None => + info(s"Nothing added or removed for ${dataDir.getAbsoluteFile} directory in updateCheckpoints.") Review comment: Removed. Thanks. ---------------------------------------------------------------- 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