KAFKA-17763 Remove Utils.covariantCast and use var for type inference (#17468)

Reviewers: Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
Logan Zhu 2024-10-14 15:22:43 +08:00 committed by GitHub
parent 4529cc4e98
commit d55b4e640c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 10 deletions

View File

@ -1526,11 +1526,6 @@ public final class Utils {
}
}
@SuppressWarnings("unchecked")
public static <S> Iterator<S> covariantCast(Iterator<? extends S> iterator) {
return (Iterator<S>) iterator;
}
/**
* Checks if a string is null, empty or whitespace only.
* @param str a string to be checked

View File

@ -105,7 +105,7 @@ public final class FileRawSnapshotTest {
int countBatches = 0;
int countRecords = 0;
Iterator<RecordBatch> batches = Utils.covariantCast(snapshot.records().batchIterator());
var batches = snapshot.records().batchIterator();
while (batches.hasNext()) {
RecordBatch batch = batches.next();
countBatches += 1;
@ -191,7 +191,7 @@ public final class FileRawSnapshotTest {
int countBatches = 0;
int countRecords = 0;
Iterator<RecordBatch> batches = Utils.covariantCast(snapshot.records().batchIterator());
var batches = snapshot.records().batchIterator();
while (batches.hasNext()) {
RecordBatch batch = batches.next();
countBatches += 1;
@ -245,7 +245,7 @@ public final class FileRawSnapshotTest {
int countBatches = 0;
int countRecords = 0;
Iterator<RecordBatch> batches = Utils.covariantCast(snapshot.records().batchIterator());
var batches = snapshot.records().batchIterator();
while (batches.hasNext()) {
RecordBatch batch = batches.next();
countBatches += 1;

View File

@ -23,7 +23,6 @@ import org.apache.kafka.common.record.Record;
import org.apache.kafka.common.record.RecordBatch;
import org.apache.kafka.common.utils.BufferSupplier;
import org.apache.kafka.common.utils.BufferSupplier.GrowableBufferSupplier;
import org.apache.kafka.common.utils.Utils;
import org.apache.kafka.raft.Batch;
import org.apache.kafka.raft.ControlRecord;
import org.apache.kafka.raft.OffsetAndEpoch;
@ -209,7 +208,7 @@ public final class SnapshotWriterReaderTest {
int countRecords = 0;
Iterator<RecordBatch> recordBatches = Utils.covariantCast(snapshot.records().batchIterator());
var recordBatches = snapshot.records().batchIterator();
assertTrue(recordBatches.hasNext());
RecordBatch batch = recordBatches.next();