You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "bachmanity1 (via GitHub)" <gi...@apache.org> on 2023/02/15 01:01:38 UTC

[GitHub] [kafka] bachmanity1 commented on a diff in pull request #13246: KAFKA-14707: Improve array size check

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

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