AndrewJSchofield commented on code in PR #24099:
URL: https://github.com/apache/kafka/pull/24099#discussion_r4512564751


##########
clients/src/main/java/org/apache/kafka/common/utils/Utils.java:
##########
@@ -333,7 +337,7 @@ public static byte[] getNullableSizePrefixedArray(final 
ByteBuffer buffer) {
      * @return The array
      */
     public static byte[] getNullableArray(final ByteBuffer buffer, final int 
size) {
-        if (size > buffer.remaining()) {
+        if (size < -1 || size > buffer.remaining()) {

Review Comment:
   This seems like a strange change. There is special-case behaviour, not in 
the Javadoc, which returns a null array if the size is -1. It doesn't seem to 
me that using size of -2 should give `BufferUnderflowException`. Either 
returning `null` for any negative size or continuing with the current behaviour 
of a `NegativeArraySizeException` seem better to me for 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: [email protected]

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

Reply via email to