chia7712 commented on code in PR #15507: URL: https://github.com/apache/kafka/pull/15507#discussion_r1523656781
########## server-common/src/main/java/org/apache/kafka/server/mutable/BoundedList.java: ########## @@ -35,24 +35,12 @@ public class BoundedList<E> implements List<E> { private final int maxLength; private final List<E> underlying; - public static <E> BoundedList<E> newArrayBacked(int maxLength) { - return new BoundedList<>(maxLength, new ArrayList<>()); - } - - public static <E> BoundedList<E> newArrayBacked(int maxLength, int initialCapacity) { - return new BoundedList<>(maxLength, new ArrayList<>(initialCapacity)); - } - - public BoundedList(int maxLength, List<E> underlying) { + public BoundedList(int maxLength) { if (maxLength <= 0) { throw new IllegalArgumentException("Invalid non-positive maxLength of " + maxLength); } this.maxLength = maxLength; - if (underlying.size() > maxLength) { - throw new BoundedListTooLongException("Cannot wrap list, because it is longer than " + - "the maximum length " + maxLength); - } - this.underlying = underlying; + this.underlying = new ArrayList<>(maxLength); Review Comment: It seems to me the large batch operation is not usual. It could be a potential performance regression if we always create `ArrayList` with `10000` initial size. If the origin constructor has potential issue about using a reference to `underlying`, we can change it from `public` to `private`. ########## server-common/src/main/java/org/apache/kafka/server/mutable/BoundedList.java: ########## @@ -35,24 +35,12 @@ public class BoundedList<E> implements List<E> { private final int maxLength; private final List<E> underlying; - public static <E> BoundedList<E> newArrayBacked(int maxLength) { - return new BoundedList<>(maxLength, new ArrayList<>()); - } - - public static <E> BoundedList<E> newArrayBacked(int maxLength, int initialCapacity) { Review Comment: The operation which we can ensure the size of batch before processing can use this method. -- 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-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org