mjsax commented on code in PR #22755:
URL: https://github.com/apache/kafka/pull/22755#discussion_r3625975657


##########
clients/src/main/java/org/apache/kafka/common/serialization/ListDeserializer.java:
##########
@@ -196,7 +195,12 @@ public List<Inner> deserialize(String topic, Headers 
headers, byte[] data) {
                     continue;
                 }
                 byte[] payload = new byte[entrySize];
-                if (dis.read(payload) == -1) {
+                try {
+                    // Use readFully (not read) so a stream truncated 
mid-entry is detected: read(byte[]) may
+                    // return a partial count without reaching EOF, which 
would silently leave the tail of the
+                    // payload zero-filled and hand a corrupted entry to the 
inner deserializer.
+                    dis.readFully(payload);
+                } catch (EOFException e) {

Review Comment:
   Would it be simpler to keep using `read()` and check for `!= entrySize` ? -- 
This way, we don't have to deal with exceptions.



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