MINOR: Fix KRaft snapshot delete bug in Scala 2.12
The sliding window + takeWhile behavior over a sequence seems somewhat
different between Scala 2.12 and Scala 2.13. This PR works around the
difference by using foreach with an early return.
Reviewers: Colin P. McCabe
@@ -404,13 +404,12 @@ 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
} else {
- false
+ return didClean
}
case _ => false // Shouldn't get here with the sliding window
}
