Prechádzať zdrojové kódy

Do not choke on MessageSet without version

If we end un unlucky and MessageSet buffer is truncated right before
we can read magic value, we just return `ErrInsufficientData`, even
if some messages were previously successfully parsed.

This propagates all the way up to `partitionConsumer`, where we zero
parsed messages, which results in `ErrMessageTooLarge` returned
to the consumer.

This commit fixes the issue by setting `PartialTrailingMessage` to `true`
on `MessageSet`, making it possible to read successfully parsed messages.
Ivan Babrou 7 rokov pred
rodič
commit
885c1b09e5
1 zmenil súbory, kde vykonal 4 pridanie a 0 odobranie
  1. 4 0
      message_set.go

+ 4 - 0
message_set.go

@@ -66,6 +66,10 @@ func (ms *MessageSet) decode(pd packetDecoder) (err error) {
 	for pd.remaining() > 0 {
 		magic, err := magicValue(pd)
 		if err != nil {
+			if err == ErrInsufficientData {
+				ms.PartialTrailingMessage = true
+				return nil
+			}
 			return err
 		}