MINOR: suppress build warning (#20424)

Suppress build warning.

Reviewers: TengYao Chi <frankvicky@apache.org>, Ken Huang
<s7133700@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
Matthias J. Sax 2025-09-01 11:12:11 -07:00 committed by GitHub
parent 4f2114a49e
commit 342a8e6773
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 34 additions and 12 deletions

View File

@ -311,7 +311,7 @@ public class ClientsTestUtils {
Optional<Map<TopicPartition, OffsetAndMetadata>> offsetsOpt Optional<Map<TopicPartition, OffsetAndMetadata>> offsetsOpt
) throws InterruptedException { ) throws InterruptedException {
var commitCallback = new RetryCommitCallback(consumer, offsetsOpt); var commitCallback = new RetryCommitCallback<>(consumer, offsetsOpt);
sendAsyncCommit(consumer, commitCallback, offsetsOpt); sendAsyncCommit(consumer, commitCallback, offsetsOpt);
TestUtils.waitForCondition(() -> { TestUtils.waitForCondition(() -> {

View File

@ -137,6 +137,7 @@ public class MetricsDuringTopicCreationDeletionTest {
} }
} }
@SuppressWarnings("unchecked")
private Gauge<Integer> getGauge(String metricName) { private Gauge<Integer> getGauge(String metricName) {
return KafkaYammerMetrics.defaultRegistry().allMetrics().entrySet().stream() return KafkaYammerMetrics.defaultRegistry().allMetrics().entrySet().stream()
.filter(entry -> entry.getKey().getName().endsWith(metricName)) .filter(entry -> entry.getKey().getName().endsWith(metricName))

View File

@ -123,6 +123,7 @@ public class ClientTelemetryTest {
} }
} }
@SuppressWarnings("unchecked")
@ClusterTest(types = {Type.CO_KRAFT, Type.KRAFT}) @ClusterTest(types = {Type.CO_KRAFT, Type.KRAFT})
public void testIntervalMsParser(ClusterInstance clusterInstance) { public void testIntervalMsParser(ClusterInstance clusterInstance) {
List<String> alterOpts = asList("--bootstrap-server", clusterInstance.bootstrapServers(), List<String> alterOpts = asList("--bootstrap-server", clusterInstance.bootstrapServers(),
@ -152,6 +153,7 @@ public class ClientTelemetryTest {
} }
} }
@SuppressWarnings("unchecked")
private static String[] toArray(List<String>... lists) { private static String[] toArray(List<String>... lists) {
return Stream.of(lists).flatMap(List::stream).toArray(String[]::new); return Stream.of(lists).flatMap(List::stream).toArray(String[]::new);
} }

View File

@ -168,6 +168,7 @@ public class WorkerTestUtils {
"Wrong rebalance delay in " + assignment); "Wrong rebalance delay in " + assignment);
} }
@SuppressWarnings("unchecked")
public static <T, R extends ConnectRecord<R>> TransformationChain<T, R> getTransformationChain( public static <T, R extends ConnectRecord<R>> TransformationChain<T, R> getTransformationChain(
RetryWithToleranceOperator<T> toleranceOperator, RetryWithToleranceOperator<T> toleranceOperator,
List<Object> results) { List<Object> results) {

View File

@ -1278,6 +1278,7 @@ public class DelayedShareFetchTest {
assertEquals(1, delayedShareFetch.expiredRequestMeter().count()); assertEquals(1, delayedShareFetch.expiredRequestMeter().count());
} }
@SuppressWarnings("unchecked")
@Test @Test
public void testRemoteStorageFetchTryCompleteReturnsFalse() { public void testRemoteStorageFetchTryCompleteReturnsFalse() {
ReplicaManager replicaManager = mock(ReplicaManager.class); ReplicaManager replicaManager = mock(ReplicaManager.class);
@ -1357,6 +1358,7 @@ public class DelayedShareFetchTest {
delayedShareFetch.lock().unlock(); delayedShareFetch.lock().unlock();
} }
@SuppressWarnings("unchecked")
@Test @Test
public void testRemoteStorageFetchPartitionLeaderChanged() { public void testRemoteStorageFetchPartitionLeaderChanged() {
ReplicaManager replicaManager = mock(ReplicaManager.class); ReplicaManager replicaManager = mock(ReplicaManager.class);
@ -1421,6 +1423,7 @@ public class DelayedShareFetchTest {
delayedShareFetch.lock().unlock(); delayedShareFetch.lock().unlock();
} }
@SuppressWarnings("unchecked")
@Test @Test
public void testRemoteStorageFetchTryCompleteThrowsException() { public void testRemoteStorageFetchTryCompleteThrowsException() {
ReplicaManager replicaManager = mock(ReplicaManager.class); ReplicaManager replicaManager = mock(ReplicaManager.class);
@ -1507,6 +1510,7 @@ public class DelayedShareFetchTest {
delayedShareFetch.lock().unlock(); delayedShareFetch.lock().unlock();
} }
@SuppressWarnings("unchecked")
@Test @Test
public void testRemoteStorageFetchTryCompletionDueToBrokerBecomingOffline() { public void testRemoteStorageFetchTryCompletionDueToBrokerBecomingOffline() {
ReplicaManager replicaManager = mock(ReplicaManager.class); ReplicaManager replicaManager = mock(ReplicaManager.class);
@ -2197,6 +2201,7 @@ public class DelayedShareFetchTest {
return mock(BiConsumer.class); return mock(BiConsumer.class);
} }
@SuppressWarnings("unchecked")
static class DelayedShareFetchBuilder { static class DelayedShareFetchBuilder {
private ShareFetch shareFetch = mock(ShareFetch.class); private ShareFetch shareFetch = mock(ShareFetch.class);
private ReplicaManager replicaManager = mock(ReplicaManager.class); private ReplicaManager replicaManager = mock(ReplicaManager.class);

View File

@ -2470,7 +2470,6 @@ public class SharePartitionManagerTest {
} }
@Test @Test
@SuppressWarnings("unchecked")
public void testShareFetchProcessingExceptions() throws Exception { public void testShareFetchProcessingExceptions() throws Exception {
String groupId = "grp"; String groupId = "grp";
TopicIdPartition tp0 = new TopicIdPartition(Uuid.randomUuid(), new TopicPartition("foo", 0)); TopicIdPartition tp0 = new TopicIdPartition(Uuid.randomUuid(), new TopicPartition("foo", 0));
@ -3232,6 +3231,7 @@ public class SharePartitionManagerTest {
return CollectionConverters.asScala(logReadResults).toSeq(); return CollectionConverters.asScala(logReadResults).toSeq();
} }
@SuppressWarnings("unchecked")
static void mockReplicaManagerDelayedShareFetch(ReplicaManager replicaManager, static void mockReplicaManagerDelayedShareFetch(ReplicaManager replicaManager,
DelayedOperationPurgatory<DelayedShareFetch> delayedShareFetchPurgatory) { DelayedOperationPurgatory<DelayedShareFetch> delayedShareFetchPurgatory) {
doAnswer(invocationOnMock -> { doAnswer(invocationOnMock -> {

View File

@ -110,6 +110,7 @@ import static org.mockito.ArgumentMatchers.anyList;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@SuppressWarnings("resource")
public class SharePartitionTest { public class SharePartitionTest {
private static final String ACQUISITION_LOCK_NEVER_GOT_RELEASED = "Acquisition lock never got released."; private static final String ACQUISITION_LOCK_NEVER_GOT_RELEASED = "Acquisition lock never got released.";
@ -7991,6 +7992,7 @@ public class SharePartitionTest {
assertNotNull(sharePartition.cachedState().get(50L).offsetState().get(69L).acquisitionLockTimeoutTask()); assertNotNull(sharePartition.cachedState().get(50L).offsetState().get(69L).acquisitionLockTimeoutTask());
} }
@SuppressWarnings({"rawtypes", "unchecked"})
@Test @Test
public void testContainsAbortMarker() { public void testContainsAbortMarker() {
SharePartition sharePartition = SharePartitionBuilder.builder() SharePartition sharePartition = SharePartitionBuilder.builder()

View File

@ -160,6 +160,7 @@ public class ControllerMetadataMetricsTest {
); );
} }
@SuppressWarnings("unchecked") // suppress warning about Gauge typecast
@Test @Test
public void testBrokerRegistrationStateMetrics() { public void testBrokerRegistrationStateMetrics() {
MetricsRegistry registry = new MetricsRegistry(); MetricsRegistry registry = new MetricsRegistry();

View File

@ -164,6 +164,7 @@ public class QuorumControllerMetricsTest {
} }
} }
@SuppressWarnings("unchecked")
@Test @Test
public void testTimeSinceLastHeartbeatReceivedMs() { public void testTimeSinceLastHeartbeatReceivedMs() {
MetricsRegistry registry = new MetricsRegistry(); MetricsRegistry registry = new MetricsRegistry();

View File

@ -55,8 +55,8 @@ public class CommandLineUtilsTest {
List<String> argArray = List.of("my.empty.property=", "my.empty.property1"); List<String> argArray = List.of("my.empty.property=", "my.empty.property1");
Properties props = CommandLineUtils.parseKeyValueArgs(argArray); Properties props = CommandLineUtils.parseKeyValueArgs(argArray);
assertEquals(props.getProperty("my.empty.property"), "", "Value of a key with missing value should be an empty string"); assertEquals("", props.getProperty("my.empty.property"), "Value of a key with missing value should be an empty string");
assertEquals(props.getProperty("my.empty.property1"), "", "Value of a key with missing value with no delimiter should be an empty string"); assertEquals("", props.getProperty("my.empty.property1"), "Value of a key with missing value with no delimiter should be an empty string");
} }
@Test @Test
@ -64,7 +64,7 @@ public class CommandLineUtilsTest {
List<String> argArray = List.of("my.property=value"); List<String> argArray = List.of("my.property=value");
Properties props = CommandLineUtils.parseKeyValueArgs(argArray); Properties props = CommandLineUtils.parseKeyValueArgs(argArray);
assertEquals(props.getProperty("my.property"), "value", "Value of a single property should be 'value'"); assertEquals("value", props.getProperty("my.property"), "Value of a single property should be 'value'");
} }
@Test @Test
@ -72,8 +72,8 @@ public class CommandLineUtilsTest {
List<String> argArray = List.of("first.property=first", "second.property=second"); List<String> argArray = List.of("first.property=first", "second.property=second");
Properties props = CommandLineUtils.parseKeyValueArgs(argArray); Properties props = CommandLineUtils.parseKeyValueArgs(argArray);
assertEquals(props.getProperty("first.property"), "first", "Value of first property should be 'first'"); assertEquals("first", props.getProperty("first.property"), "Value of first property should be 'first'");
assertEquals(props.getProperty("second.property"), "second", "Value of second property should be 'second'"); assertEquals("second", props.getProperty("second.property"), "Value of second property should be 'second'");
} }
@Test @Test
@ -81,9 +81,9 @@ public class CommandLineUtilsTest {
List<String> argArray = List.of("first.property==first", "second.property=second=", "third.property=thi=rd"); List<String> argArray = List.of("first.property==first", "second.property=second=", "third.property=thi=rd");
Properties props = CommandLineUtils.parseKeyValueArgs(argArray); Properties props = CommandLineUtils.parseKeyValueArgs(argArray);
assertEquals(props.getProperty("first.property"), "=first", "Value of first property should be '=first'"); assertEquals("=first", props.getProperty("first.property"), "Value of first property should be '=first'");
assertEquals(props.getProperty("second.property"), "second=", "Value of second property should be 'second='"); assertEquals("second=", props.getProperty("second.property"), "Value of second property should be 'second='");
assertEquals(props.getProperty("third.property"), "thi=rd", "Value of second property should be 'thi=rd'"); assertEquals("thi=rd", props.getProperty("third.property"), "Value of second property should be 'thi=rd'");
} }
Properties props = new Properties(); Properties props = new Properties();
@ -272,6 +272,7 @@ public class CommandLineUtilsTest {
Optional.of("127.0.0.2:9094"), Optional.of("127.0.0.3:9095"))).getMessage()); Optional.of("127.0.0.2:9094"), Optional.of("127.0.0.3:9095"))).getMessage());
} }
@SuppressWarnings("unchecked")
private OptionSpec<String> createMockOptionSpec(String name) { private OptionSpec<String> createMockOptionSpec(String name) {
OptionSpec<String> spec = mock(OptionSpec.class); OptionSpec<String> spec = mock(OptionSpec.class);
when(spec.toString()).thenReturn("[" + name.replaceAll("--", "") + "]"); when(spec.toString()).thenReturn("[" + name.replaceAll("--", "") + "]");

View File

@ -479,6 +479,7 @@ public class ClientQuotasRequestTest {
} }
} }
@SuppressWarnings("unchecked")
private void testMatchEntities(ClientQuotaFilter filter, int expectedMatchSize, Predicate<ClientQuotaEntity> partition) private void testMatchEntities(ClientQuotaFilter filter, int expectedMatchSize, Predicate<ClientQuotaEntity> partition)
throws InterruptedException { throws InterruptedException {
TestUtils.retryOnExceptionWithTimeout(5000L, () -> { TestUtils.retryOnExceptionWithTimeout(5000L, () -> {

View File

@ -60,6 +60,7 @@ import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@SuppressWarnings("resource")
@ClusterTestDefaults(brokers = 3) @ClusterTestDefaults(brokers = 3)
public class TopicBasedRemoteLogMetadataManagerTest { public class TopicBasedRemoteLogMetadataManagerTest {
private static final int SEG_SIZE = 1048576; private static final int SEG_SIZE = 1048576;
@ -106,6 +107,7 @@ public class TopicBasedRemoteLogMetadataManagerTest {
} }
} }
@SuppressWarnings("unchecked")
@ClusterTest @ClusterTest
public void testDoesTopicExistWithAdminClientExecutionError() throws ExecutionException, InterruptedException { public void testDoesTopicExistWithAdminClientExecutionError() throws ExecutionException, InterruptedException {
// Create a mock Admin client that throws an ExecutionException (not UnknownTopicOrPartitionException) // Create a mock Admin client that throws an ExecutionException (not UnknownTopicOrPartitionException)

View File

@ -381,6 +381,7 @@ public class RemoteLogManagerTest {
assertFalse(remoteStorageManagerConfig.containsKey("remote.storage.manager.y")); assertFalse(remoteStorageManagerConfig.containsKey("remote.storage.manager.y"));
} }
@SuppressWarnings("unchecked")
@Test @Test
void testRemoteLogMetadataManagerWithEndpointConfig() { void testRemoteLogMetadataManagerWithEndpointConfig() {
ArgumentCaptor<Map<String, Object>> capture = ArgumentCaptor.forClass(Map.class); ArgumentCaptor<Map<String, Object>> capture = ArgumentCaptor.forClass(Map.class);
@ -391,6 +392,7 @@ public class RemoteLogManagerTest {
assertEquals(brokerId, capture.getValue().get(ServerConfigs.BROKER_ID_CONFIG)); assertEquals(brokerId, capture.getValue().get(ServerConfigs.BROKER_ID_CONFIG));
} }
@SuppressWarnings("unchecked")
@Test @Test
void testRemoteLogMetadataManagerWithEndpointConfigOverridden() throws IOException { void testRemoteLogMetadataManagerWithEndpointConfigOverridden() throws IOException {
Properties props = new Properties(); Properties props = new Properties();
@ -430,6 +432,7 @@ public class RemoteLogManagerTest {
} }
} }
@SuppressWarnings("unchecked")
@Test @Test
void testConfigure() { void testConfigure() {
ArgumentCaptor<Map<String, Object>> capture = ArgumentCaptor.forClass(Map.class); ArgumentCaptor<Map<String, Object>> capture = ArgumentCaptor.forClass(Map.class);
@ -2071,6 +2074,7 @@ public class RemoteLogManagerTest {
assertEquals(expected, actual); assertEquals(expected, actual);
} }
@SuppressWarnings("unchecked")
@Test @Test
public void testRemoteSizeData() { public void testRemoteSizeData() {
Supplier<RemoteLogManager.RetentionSizeData>[] invalidRetentionSizeData = Supplier<RemoteLogManager.RetentionSizeData>[] invalidRetentionSizeData =
@ -2087,6 +2091,7 @@ public class RemoteLogManagerTest {
} }
} }
@SuppressWarnings("unchecked")
@Test @Test
public void testRemoteSizeTime() { public void testRemoteSizeTime() {
Supplier<RemoteLogManager.RetentionTimeData>[] invalidRetentionTimeData = Supplier<RemoteLogManager.RetentionTimeData>[] invalidRetentionTimeData =

View File

@ -1961,6 +1961,7 @@ public class RecordCollectorTest {
} }
@SuppressWarnings("deprecation")
@Override @Override
public ProductionExceptionHandlerResponse handle(final ErrorHandlerContext context, final ProducerRecord<byte[], byte[]> record, final Exception exception) { public ProductionExceptionHandlerResponse handle(final ErrorHandlerContext context, final ProducerRecord<byte[], byte[]> record, final Exception exception) {
sourceRawData[0] = context.sourceRawKey(); sourceRawData[0] = context.sourceRawKey();
@ -1978,15 +1979,14 @@ public class RecordCollectorTest {
assertNull(sourceRawData[1]); assertNull(sourceRawData[1]);
} }
@Test @Test
public void shouldHaveRawDataDuringExceptionInSerialization() { public void shouldHaveRawDataDuringExceptionInSerialization() {
final byte[][] sourceRawData = new byte[][]{new byte[]{}, new byte[]{}}; final byte[][] sourceRawData = new byte[][]{new byte[]{}, new byte[]{}};
try (final ErrorStringSerializer errorSerializer = new ErrorStringSerializer()) { try (final ErrorStringSerializer errorSerializer = new ErrorStringSerializer()) {
final RecordCollector collector = newRecordCollector( final RecordCollector collector = newRecordCollector(
new ProductionExceptionHandler() { new ProductionExceptionHandler() {
@SuppressWarnings({"deprecation", "rawtypes"})
@Override @Override
@SuppressWarnings({"rawtypes", "unused"})
public ProductionExceptionHandlerResponse handleSerializationException(final ErrorHandlerContext context, final ProducerRecord record, final Exception exception, final SerializationExceptionOrigin origin) { public ProductionExceptionHandlerResponse handleSerializationException(final ErrorHandlerContext context, final ProducerRecord record, final Exception exception, final SerializationExceptionOrigin origin) {
sourceRawData[0] = context.sourceRawKey(); sourceRawData[0] = context.sourceRawKey();
sourceRawData[1] = context.sourceRawValue(); sourceRawData[1] = context.sourceRawValue();