hachikuji commented on a change in pull request #9563:
URL: https://github.com/apache/kafka/pull/9563#discussion_r519971686



##########
File path: 
generator/src/main/java/org/apache/kafka/message/MessageDataGenerator.java
##########
@@ -1579,58 +1566,58 @@ private void generateVariableLengthFieldSize(FieldSpec 
field,
                     }
                     if (tagged) {
                         
headerGenerator.addImport(MessageGenerator.BYTE_UTILS_CLASS);
+                        buffer.printf("int _arraySize = _size.totalSize() - 
_sizeBeforeArray;%n");
                         buffer.printf("_cache.setArraySizeInBytes(%s, 
_arraySize);%n",
                             field.camelCaseName());
-                        buffer.printf("_size += _arraySize + 
ByteUtils.sizeOfUnsignedVarint(_arraySize);%n");
-                    } else {
-                        buffer.printf("_size += _arraySize;%n");
+                        
buffer.printf("_size.addBytes(ByteUtils.sizeOfUnsignedVarint(_arraySize));%n");
                     }
                 } else if (field.type().isBytes()) {
+                    buffer.printf("int _sizeBeforeBytes = 
_size.totalSize();%n");

Review comment:
       Good catch




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

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


Reply via email to