You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "divijvaidya (via GitHub)" <gi...@apache.org> on 2023/12/25 16:07:16 UTC

[PR] MINOR: New year code clean up (part 1) [kafka]

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

   Multiple clean ups for `warn` discovered via automatic tooling (different ones). No logic change.
   
   Types of clean up:
   1. Remove redundant imports
   2. Use bulk collection operations such as `putAll` instead of iteration
   3. Replace `Arrays.asList()` with `Collections.singletonList()`
   4. Remove String concatenation in a loop, use StringBuilder instead
   5. Replace `if` with `switch`
   6. Use `compare()` to compare integers
   7. Loop is replaces with `Collection.removeIf()`
   8. Replace StringBuffer with StringBuilder
   9. Replace `for` with enhanced `for` loop
   10. Replace redundant `Collection.addAll()` with parameterized constructor call
   11. Use `%d` with integers instead of `%s`
   12. Replace `String.equals("")` with `String.isEmpty()`
   13. Replace `Collections.sort()` with `List.sort()` where applicable
   14. Replace `System.getProperty("line.separator")` with `System.lineSeparator()`


-- 
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: New year code clean up - misc [kafka]

Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on PR #15071:
URL: https://github.com/apache/kafka/pull/15071#issuecomment-1887126184

   (rebased from trunk to resolve conflict, will merge after CI is sane)


-- 
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: New year code clean up - misc [kafka]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #15071:
URL: https://github.com/apache/kafka/pull/15071#issuecomment-2571488474

   This PR has been closed since it has not had any activity in 120 days. If you feel like this
   was a mistake, or you would like to continue working on it, please feel free to re-open the 
   PR and ask for a review.


-- 
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: New year code clean up - misc [kafka]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #15071: MINOR: New year code clean up - misc
URL: https://github.com/apache/kafka/pull/15071


-- 
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: New year code clean up - misc [kafka]

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


##########
trogdor/src/main/java/org/apache/kafka/trogdor/workload/TopicsSpec.java:
##########
@@ -67,8 +67,7 @@ public void set(String name, PartitionsSpec value) {
     }
 
     public TopicsSpec immutableCopy() {
-        HashMap<String, PartitionsSpec> mapCopy = new HashMap<>();
-        mapCopy.putAll(map);
+        HashMap<String, PartitionsSpec> mapCopy = new HashMap<>(map);

Review Comment:
   done



-- 
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: New year code clean up - misc [kafka]

Posted by "mimaison (via GitHub)" <gi...@apache.org>.
mimaison commented on PR #15071:
URL: https://github.com/apache/kafka/pull/15071#issuecomment-1923992830

   This needs another rebase.


-- 
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: New year code clean up - misc [kafka]

Posted by "divijvaidya (via GitHub)" <gi...@apache.org>.
divijvaidya commented on PR #15071:
URL: https://github.com/apache/kafka/pull/15071#issuecomment-1870147486

   @ijuma requesting your review on this cleanup as well please.


-- 
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: New year code clean up - misc [kafka]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #15071:
URL: https://github.com/apache/kafka/pull/15071#issuecomment-2185520326

   This PR is being marked as stale since it has not had any activity in 90 days. If you would like to keep this PR alive, please ask a committer for review. If the PR has  merge conflicts, please update it with the latest from trunk (or appropriate release branch) <p> If this PR is no longer valid or desired, please feel free to close it. If no activity occurs in the next 30 days, it will be automatically closed.


-- 
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: New year code clean up - misc [kafka]

Posted by "chia7712 (via GitHub)" <gi...@apache.org>.
chia7712 commented on PR #15071:
URL: https://github.com/apache/kafka/pull/15071#issuecomment-2017572670

   any update here?


-- 
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: New year code clean up - misc [kafka]

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


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/CommitRequestManager.java:
##########
@@ -1079,8 +1077,7 @@ private void clearAll() {
         }
 
         private List<NetworkClientDelegate.UnsentRequest> drainPendingCommits() {
-            ArrayList<NetworkClientDelegate.UnsentRequest> res = new ArrayList<>();
-            res.addAll(unsentOffsetCommits.stream().map(OffsetCommitRequestState::toUnsentRequest).collect(Collectors.toList()));
+            ArrayList<NetworkClientDelegate.UnsentRequest> res = new ArrayList<>(unsentOffsetCommits.stream().map(OffsetCommitRequestState::toUnsentRequest).collect(Collectors.toList()));

Review Comment:
   We can use `List` on the left



##########
trogdor/src/main/java/org/apache/kafka/trogdor/workload/TopicsSpec.java:
##########
@@ -67,8 +67,7 @@ public void set(String name, PartitionsSpec value) {
     }
 
     public TopicsSpec immutableCopy() {
-        HashMap<String, PartitionsSpec> mapCopy = new HashMap<>();
-        mapCopy.putAll(map);
+        HashMap<String, PartitionsSpec> mapCopy = new HashMap<>(map);

Review Comment:
   Can we use `Map` on the left side?



-- 
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: New year code clean up - misc [kafka]

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


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/CommitRequestManager.java:
##########
@@ -1079,8 +1077,7 @@ private void clearAll() {
         }
 
         private List<NetworkClientDelegate.UnsentRequest> drainPendingCommits() {
-            ArrayList<NetworkClientDelegate.UnsentRequest> res = new ArrayList<>();
-            res.addAll(unsentOffsetCommits.stream().map(OffsetCommitRequestState::toUnsentRequest).collect(Collectors.toList()));
+            ArrayList<NetworkClientDelegate.UnsentRequest> res = new ArrayList<>(unsentOffsetCommits.stream().map(OffsetCommitRequestState::toUnsentRequest).collect(Collectors.toList()));

Review Comment:
   done



-- 
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