bachmanity1 commented on code in PR #13246:
URL: https://github.com/apache/kafka/pull/13246#discussion_r1106542835


##########
clients/src/main/java/org/apache/kafka/common/protocol/types/ArrayOf.java:
##########
@@ -72,10 +74,10 @@ public Object read(ByteBuffer buffer) {
         else if (size < 0)
             throw new SchemaException("Array size " + size + " cannot be 
negative");
 
-        Object[] objs = new Object[size];
+        List<Object> objs = new ArrayList<>();
         for (int i = 0; i < size; i++)
-            objs[i] = type.read(buffer);
-        return objs;
+            objs.add(type.read(buffer));
+        return objs.toArray();

Review Comment:
   > Checking for OOM is a security issue, so we cannot do that as the main 
approach. We need to do pre-validation.
   
   @ijuma 
   Then how about using a list instead of an array? I know this might have a 
negative impact on performance but it seems to resolve OOM issue. 



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

Reply via email to