dengziming commented on a change in pull request #10793:
URL: https://github.com/apache/kafka/pull/10793#discussion_r645206278



##########
File path: 
server-common/src/main/java/org/apache/kafka/server/common/serialization/AbstractApiMessageSerde.java
##########
@@ -69,16 +76,42 @@ public void write(ApiMessageAndVersion data,
     @Override
     public ApiMessageAndVersion read(Readable input,
                                      int size) {
-        short frameVersion = (short) input.readUnsignedVarint();
+        short frameVersion;
+        try {
+            frameVersion = unsignedIntToShort(input.readUnsignedVarint(), 
"frame version");
+        } catch (Exception e) {
+            throw new MetadataParseException("Failed to read variable-length " 
+

Review comment:
       In fact `input.readUnsignedVarint()` may throw a 
IlleagelArgumentException if it fails to read a short, this can be seen in 
`MetadataRecordSerdeTest.testParsingMalformedFrameVersionVarint`.




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