smjn commented on code in PR #22122:
URL: https://github.com/apache/kafka/pull/22122#discussion_r3246915213


##########
clients/src/main/java/org/apache/kafka/common/Uuid.java:
##########
@@ -189,8 +185,6 @@ public static Uuid[] toArray(List<Uuid> list) {
      */
     public static List<Uuid> toList(Uuid[] array) {
         if (array == null) return null;
-        List<Uuid> list = new ArrayList<>(array.length);
-        list.addAll(Arrays.asList(array));
-        return list;
+        return new ArrayList<>(Arrays.asList(array));

Review Comment:
   @mirkoalicastro Is there any usage where the returned collection is being 
modified? If it is, it isn't correct considering general `toXXX` method in 
JAVA. It should be immutable.
   If you want it to be mutable, then the previous impl was better - you are 
creating 2 arraylists otherwise, which is not required.



##########
clients/src/main/java/org/apache/kafka/common/Uuid.java:
##########
@@ -189,8 +185,6 @@ public static Uuid[] toArray(List<Uuid> list) {
      */
     public static List<Uuid> toList(Uuid[] array) {
         if (array == null) return null;
-        List<Uuid> list = new ArrayList<>(array.length);
-        list.addAll(Arrays.asList(array));
-        return list;
+        return new ArrayList<>(Arrays.asList(array));

Review Comment:
   @mirkoalicastro Is there any usage where the returned collection is being 
modified? If it is, it isn't correct considering general `toXXX` methods in 
JAVA. It should be immutable.
   If you want it to be mutable, then the previous impl was better - you are 
creating 2 arraylists otherwise, which is not required.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to