You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "YutaLin (via GitHub)" <gi...@apache.org> on 2025/05/12 00:18:27 UTC

[PR] MINOR: Fix unchecked type warnings in several test classes [kafka]

YutaLin opened a new pull request, #19679:
URL: https://github.com/apache/kafka/pull/19679

   * In ConsoleShareConsumerTest, add @SuppressWarnings("unchecked") annotation in method shouldUpgradeDeliveryCount
   * In ListConsumerGroupOffsetsHandlerTest, add generic parameters to HashSet constructors
   * In TopicsImageTest, add explicit generic type to Collections.EMPTY_MAP to fix raw type usage
   
   Reviewers: Chia-Ping Tsai
   [chia7712@gmail.com](mailto:chia7712@gmail.com)


-- 
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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Fix unchecked type warnings in several test classes [kafka]

Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 merged PR #19679:
URL: https://github.com/apache/kafka/pull/19679


-- 
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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Fix unchecked type warnings in several test classes [kafka]

Posted by "frankvicky (via GitHub)" <gi...@apache.org>.
frankvicky commented on code in PR #19679:
URL: https://github.com/apache/kafka/pull/19679#discussion_r2083748605


##########
metadata/src/test/java/org/apache/kafka/image/TopicsImageTest.java:
##########
@@ -446,7 +446,7 @@ public void testClearElrRecordForNonExistTopic() {
 
     @Test
     public void testTopicDeltaElectionStatsWithEmptyImage() {
-        TopicImage image = new TopicImage("topic", Uuid.randomUuid(), Collections.EMPTY_MAP);
+        TopicImage image = new TopicImage("topic", Uuid.randomUuid(), Collections.<Integer, PartitionRegistration>emptyMap());

Review Comment:
   `Collections.emptyMap()`



-- 
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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Fix unchecked type warnings in several test classes [kafka]

Posted by "m1a2st (via GitHub)" <gi...@apache.org>.
m1a2st commented on code in PR #19679:
URL: https://github.com/apache/kafka/pull/19679#discussion_r2083777217


##########
metadata/src/test/java/org/apache/kafka/image/TopicsImageTest.java:
##########
@@ -446,7 +446,7 @@ public void testClearElrRecordForNonExistTopic() {
 
     @Test
     public void testTopicDeltaElectionStatsWithEmptyImage() {
-        TopicImage image = new TopicImage("topic", Uuid.randomUuid(), Collections.EMPTY_MAP);
+        TopicImage image = new TopicImage("topic", Uuid.randomUuid(), Collections.<Integer, PartitionRegistration>emptyMap());

Review Comment:
   `Collections.emptyMap()` is part of the older Java API, while `Map.of()` is the modern alternative. Since other PRs are also cleaning up the legacy API usage, we should avoid using the old API in new code.



-- 
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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Fix unchecked type warnings in several test classes [kafka]

Posted by "frankvicky (via GitHub)" <gi...@apache.org>.
frankvicky commented on code in PR #19679:
URL: https://github.com/apache/kafka/pull/19679#discussion_r2083898755


##########
metadata/src/test/java/org/apache/kafka/image/TopicsImageTest.java:
##########
@@ -446,7 +446,7 @@ public void testClearElrRecordForNonExistTopic() {
 
     @Test
     public void testTopicDeltaElectionStatsWithEmptyImage() {
-        TopicImage image = new TopicImage("topic", Uuid.randomUuid(), Collections.EMPTY_MAP);
+        TopicImage image = new TopicImage("topic", Uuid.randomUuid(), Collections.<Integer, PartitionRegistration>emptyMap());

Review Comment:
   > Just wondering, what's the purpose of the screenshot?
   Prove the patch works and make the reviewer's life easier.



##########
metadata/src/test/java/org/apache/kafka/image/TopicsImageTest.java:
##########
@@ -446,7 +446,7 @@ public void testClearElrRecordForNonExistTopic() {
 
     @Test
     public void testTopicDeltaElectionStatsWithEmptyImage() {
-        TopicImage image = new TopicImage("topic", Uuid.randomUuid(), Collections.EMPTY_MAP);
+        TopicImage image = new TopicImage("topic", Uuid.randomUuid(), Collections.<Integer, PartitionRegistration>emptyMap());

Review Comment:
   > Just wondering, what's the purpose of the screenshot?
   
   Prove the patch works and make the reviewer's life easier.



-- 
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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Fix unchecked type warnings in several test classes [kafka]

Posted by "m1a2st (via GitHub)" <gi...@apache.org>.
m1a2st commented on code in PR #19679:
URL: https://github.com/apache/kafka/pull/19679#discussion_r2083766600


##########
metadata/src/test/java/org/apache/kafka/image/TopicsImageTest.java:
##########
@@ -446,7 +446,7 @@ public void testClearElrRecordForNonExistTopic() {
 
     @Test
     public void testTopicDeltaElectionStatsWithEmptyImage() {
-        TopicImage image = new TopicImage("topic", Uuid.randomUuid(), Collections.EMPTY_MAP);
+        TopicImage image = new TopicImage("topic", Uuid.randomUuid(), Collections.<Integer, PartitionRegistration>emptyMap());

Review Comment:
   We could use `Map.of()` instead of `Collections.emptyMap()`.



-- 
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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Fix unchecked type warnings in several test classes [kafka]

Posted by "YutaLin (via GitHub)" <gi...@apache.org>.
YutaLin commented on code in PR #19679:
URL: https://github.com/apache/kafka/pull/19679#discussion_r2083773873


##########
metadata/src/test/java/org/apache/kafka/image/TopicsImageTest.java:
##########
@@ -446,7 +446,7 @@ public void testClearElrRecordForNonExistTopic() {
 
     @Test
     public void testTopicDeltaElectionStatsWithEmptyImage() {
-        TopicImage image = new TopicImage("topic", Uuid.randomUuid(), Collections.EMPTY_MAP);
+        TopicImage image = new TopicImage("topic", Uuid.randomUuid(), Collections.<Integer, PartitionRegistration>emptyMap());

Review Comment:
   Hi @frankvicky, here it is. Just wondering, what's the purpose of the screenshot?
   <img width="1290" alt="Screenshot 2025-05-11 at 11 45 58 PM" src="https://github.com/user-attachments/assets/1e208779-94d2-4917-b971-54d97902ffda" />
   
   Hi @m1a2st 
   What's the benefit to use `Map.of()` instead of `Collections.emptyMap()`



-- 
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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] MINOR: Fix unchecked type warnings in several test classes [kafka]

Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on code in PR #19679:
URL: https://github.com/apache/kafka/pull/19679#discussion_r2085087191


##########
clients/src/test/java/org/apache/kafka/clients/admin/internals/ListConsumerGroupOffsetsHandlerTest.java:
##########
@@ -158,7 +158,7 @@ public void testBuildRequestWithMultipleGroups() {
                             .setPartitionIndexes(List.of(t2p0.partition(), t2p1.partition(), t2p2.partition()))
                     ))
             ),
-            new HashSet(request1.data().groups())
+            new HashSet<>(request1.data().groups())

Review Comment:
   How about `Set.copyOf`?



##########
clients/src/test/java/org/apache/kafka/clients/admin/internals/ListConsumerGroupOffsetsHandlerTest.java:
##########
@@ -173,7 +173,7 @@ public void testBuildRequestWithMultipleGroups() {
                             .setPartitionIndexes(List.of(t3p0.partition(), t3p1.partition()))
                     ))
             ),
-            new HashSet(request2.data().groups())
+            new HashSet<>(request2.data().groups())

Review Comment:
   ditto



-- 
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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org