Skip to content

Commit 342a8e6

Browse files
authored
MINOR: suppress build warning (#20424)
Suppress build warning. Reviewers: TengYao Chi <[email protected]>, Ken Huang <[email protected]>, Chia-Ping Tsai <[email protected]>
1 parent 4f2114a commit 342a8e6

File tree

14 files changed

+34
-12
lines changed

14 files changed

+34
-12
lines changed

clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/ClientsTestUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ public static <K, V> void sendAndAwaitAsyncCommit(
311311
Optional<Map<TopicPartition, OffsetAndMetadata>> offsetsOpt
312312
) throws InterruptedException {
313313

314-
var commitCallback = new RetryCommitCallback(consumer, offsetsOpt);
314+
var commitCallback = new RetryCommitCallback<>(consumer, offsetsOpt);
315315
sendAsyncCommit(consumer, commitCallback, offsetsOpt);
316316

317317
TestUtils.waitForCondition(() -> {

clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/MetricsDuringTopicCreationDeletionTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ private void createAndDeleteTopics() {
137137
}
138138
}
139139

140+
@SuppressWarnings("unchecked")
140141
private Gauge<Integer> getGauge(String metricName) {
141142
return KafkaYammerMetrics.defaultRegistry().allMetrics().entrySet().stream()
142143
.filter(entry -> entry.getKey().getName().endsWith(metricName))

clients/clients-integration-tests/src/test/java/org/apache/kafka/clients/admin/ClientTelemetryTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ public void testClientInstanceId(ClusterInstance clusterInstance) throws Interru
123123
}
124124
}
125125

126+
@SuppressWarnings("unchecked")
126127
@ClusterTest(types = {Type.CO_KRAFT, Type.KRAFT})
127128
public void testIntervalMsParser(ClusterInstance clusterInstance) {
128129
List<String> alterOpts = asList("--bootstrap-server", clusterInstance.bootstrapServers(),
@@ -152,6 +153,7 @@ public void testMetrics(ClusterInstance clusterInstance) {
152153
}
153154
}
154155

156+
@SuppressWarnings("unchecked")
155157
private static String[] toArray(List<String>... lists) {
156158
return Stream.of(lists).flatMap(List::stream).toArray(String[]::new);
157159
}

connect/runtime/src/test/java/org/apache/kafka/connect/runtime/WorkerTestUtils.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ public static void assertAssignment(boolean expectFailed,
168168
"Wrong rebalance delay in " + assignment);
169169
}
170170

171+
@SuppressWarnings("unchecked")
171172
public static <T, R extends ConnectRecord<R>> TransformationChain<T, R> getTransformationChain(
172173
RetryWithToleranceOperator<T> toleranceOperator,
173174
List<Object> results) {

core/src/test/java/kafka/server/share/DelayedShareFetchTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,7 @@ public void testOnCompleteExecutionOnTimeout() {
12781278
assertEquals(1, delayedShareFetch.expiredRequestMeter().count());
12791279
}
12801280

1281+
@SuppressWarnings("unchecked")
12811282
@Test
12821283
public void testRemoteStorageFetchTryCompleteReturnsFalse() {
12831284
ReplicaManager replicaManager = mock(ReplicaManager.class);
@@ -1357,6 +1358,7 @@ public void testRemoteStorageFetchTryCompleteReturnsFalse() {
13571358
delayedShareFetch.lock().unlock();
13581359
}
13591360

1361+
@SuppressWarnings("unchecked")
13601362
@Test
13611363
public void testRemoteStorageFetchPartitionLeaderChanged() {
13621364
ReplicaManager replicaManager = mock(ReplicaManager.class);
@@ -1421,6 +1423,7 @@ public void testRemoteStorageFetchPartitionLeaderChanged() {
14211423
delayedShareFetch.lock().unlock();
14221424
}
14231425

1426+
@SuppressWarnings("unchecked")
14241427
@Test
14251428
public void testRemoteStorageFetchTryCompleteThrowsException() {
14261429
ReplicaManager replicaManager = mock(ReplicaManager.class);
@@ -1507,6 +1510,7 @@ public void testRemoteStorageFetchTryCompleteThrowsException() {
15071510
delayedShareFetch.lock().unlock();
15081511
}
15091512

1513+
@SuppressWarnings("unchecked")
15101514
@Test
15111515
public void testRemoteStorageFetchTryCompletionDueToBrokerBecomingOffline() {
15121516
ReplicaManager replicaManager = mock(ReplicaManager.class);
@@ -2197,6 +2201,7 @@ private static BiConsumer<SharePartitionKey, Throwable> mockExceptionHandler() {
21972201
return mock(BiConsumer.class);
21982202
}
21992203

2204+
@SuppressWarnings("unchecked")
22002205
static class DelayedShareFetchBuilder {
22012206
private ShareFetch shareFetch = mock(ShareFetch.class);
22022207
private ReplicaManager replicaManager = mock(ReplicaManager.class);

core/src/test/java/kafka/server/share/SharePartitionManagerTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2470,7 +2470,6 @@ public void testSharePartitionInitializationExceptions() throws Exception {
24702470
}
24712471

24722472
@Test
2473-
@SuppressWarnings("unchecked")
24742473
public void testShareFetchProcessingExceptions() throws Exception {
24752474
String groupId = "grp";
24762475
TopicIdPartition tp0 = new TopicIdPartition(Uuid.randomUuid(), new TopicPartition("foo", 0));
@@ -3232,6 +3231,7 @@ Compression.NONE, new SimpleRecord("test-key".getBytes(), "test-value".getBytes(
32323231
return CollectionConverters.asScala(logReadResults).toSeq();
32333232
}
32343233

3234+
@SuppressWarnings("unchecked")
32353235
static void mockReplicaManagerDelayedShareFetch(ReplicaManager replicaManager,
32363236
DelayedOperationPurgatory<DelayedShareFetch> delayedShareFetchPurgatory) {
32373237
doAnswer(invocationOnMock -> {

core/src/test/java/kafka/server/share/SharePartitionTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@
110110
import static org.mockito.Mockito.mock;
111111
import static org.mockito.Mockito.when;
112112

113+
@SuppressWarnings("resource")
113114
public class SharePartitionTest {
114115

115116
private static final String ACQUISITION_LOCK_NEVER_GOT_RELEASED = "Acquisition lock never got released.";
@@ -7991,6 +7992,7 @@ public void testAcquireWithReadCommittedIsolationLevel() {
79917992
assertNotNull(sharePartition.cachedState().get(50L).offsetState().get(69L).acquisitionLockTimeoutTask());
79927993
}
79937994

7995+
@SuppressWarnings({"rawtypes", "unchecked"})
79947996
@Test
79957997
public void testContainsAbortMarker() {
79967998
SharePartition sharePartition = SharePartitionBuilder.builder()

metadata/src/test/java/org/apache/kafka/controller/metrics/ControllerMetadataMetricsTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ public void testControlledShutdownCountMetric() {
160160
);
161161
}
162162

163+
@SuppressWarnings("unchecked") // suppress warning about Gauge typecast
163164
@Test
164165
public void testBrokerRegistrationStateMetrics() {
165166
MetricsRegistry registry = new MetricsRegistry();

metadata/src/test/java/org/apache/kafka/controller/metrics/QuorumControllerMetricsTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ public void testLastAppliedRecordMetrics() {
164164
}
165165
}
166166

167+
@SuppressWarnings("unchecked")
167168
@Test
168169
public void testTimeSinceLastHeartbeatReceivedMs() {
169170
MetricsRegistry registry = new MetricsRegistry();

server-common/src/test/java/org/apache/kafka/server/util/CommandLineUtilsTest.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,35 +55,35 @@ public void testParseEmptyArgAsValid() {
5555
List<String> argArray = List.of("my.empty.property=", "my.empty.property1");
5656
Properties props = CommandLineUtils.parseKeyValueArgs(argArray);
5757

58-
assertEquals(props.getProperty("my.empty.property"), "", "Value of a key with missing value should be an empty string");
59-
assertEquals(props.getProperty("my.empty.property1"), "", "Value of a key with missing value with no delimiter should be an empty string");
58+
assertEquals("", props.getProperty("my.empty.property"), "Value of a key with missing value should be an empty string");
59+
assertEquals("", props.getProperty("my.empty.property1"), "Value of a key with missing value with no delimiter should be an empty string");
6060
}
6161

6262
@Test
6363
public void testParseSingleArg() {
6464
List<String> argArray = List.of("my.property=value");
6565
Properties props = CommandLineUtils.parseKeyValueArgs(argArray);
6666

67-
assertEquals(props.getProperty("my.property"), "value", "Value of a single property should be 'value'");
67+
assertEquals("value", props.getProperty("my.property"), "Value of a single property should be 'value'");
6868
}
6969

7070
@Test
7171
public void testParseArgs() {
7272
List<String> argArray = List.of("first.property=first", "second.property=second");
7373
Properties props = CommandLineUtils.parseKeyValueArgs(argArray);
7474

75-
assertEquals(props.getProperty("first.property"), "first", "Value of first property should be 'first'");
76-
assertEquals(props.getProperty("second.property"), "second", "Value of second property should be 'second'");
75+
assertEquals("first", props.getProperty("first.property"), "Value of first property should be 'first'");
76+
assertEquals("second", props.getProperty("second.property"), "Value of second property should be 'second'");
7777
}
7878

7979
@Test
8080
public void testParseArgsWithMultipleDelimiters() {
8181
List<String> argArray = List.of("first.property==first", "second.property=second=", "third.property=thi=rd");
8282
Properties props = CommandLineUtils.parseKeyValueArgs(argArray);
8383

84-
assertEquals(props.getProperty("first.property"), "=first", "Value of first property should be '=first'");
85-
assertEquals(props.getProperty("second.property"), "second=", "Value of second property should be 'second='");
86-
assertEquals(props.getProperty("third.property"), "thi=rd", "Value of second property should be 'thi=rd'");
84+
assertEquals("=first", props.getProperty("first.property"), "Value of first property should be '=first'");
85+
assertEquals("second=", props.getProperty("second.property"), "Value of second property should be 'second='");
86+
assertEquals("thi=rd", props.getProperty("third.property"), "Value of second property should be 'thi=rd'");
8787
}
8888

8989
Properties props = new Properties();
@@ -272,6 +272,7 @@ public void testInitializeBootstrapPropertiesWithBothBootstraps() {
272272
Optional.of("127.0.0.2:9094"), Optional.of("127.0.0.3:9095"))).getMessage());
273273
}
274274

275+
@SuppressWarnings("unchecked")
275276
private OptionSpec<String> createMockOptionSpec(String name) {
276277
OptionSpec<String> spec = mock(OptionSpec.class);
277278
when(spec.toString()).thenReturn("[" + name.replaceAll("--", "") + "]");

0 commit comments

Comments
 (0)