ijuma commented on a change in pull request #10997: URL: https://github.com/apache/kafka/pull/10997#discussion_r667026140
########## File path: core/src/main/scala/kafka/raft/KafkaMetadataLog.scala ########## @@ -404,13 +404,13 @@ final class KafkaMetadataLog private ( return false var didClean = false - snapshots.keys.toSeq.sliding(2).toSeq.takeWhile { + snapshots.keys.toSeq.sliding(2).foreach { case Seq(snapshot: OffsetAndEpoch, nextSnapshot: OffsetAndEpoch) => if (predicate(snapshot) && deleteBeforeSnapshot(nextSnapshot)) { didClean = true true Review comment: Yeah, this looks weird. Also, early returns within lambdas rely on exceptions for control flow. I bet the issue from before is that `toSeq` was causing `toStream` to be invoked (the Scala Stream is is an odd collection). @mumrah If you do `toBuffer`, I suspect it would work as expected. -- 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. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org