[VOL-4293] OpenONU Adapter update for gRPC migration
Change-Id: I05300d3b95b878f44576a99a05f53f52fdc0cda1
diff --git a/vendor/github.com/Shopify/sarama/control_record.go b/vendor/github.com/Shopify/sarama/control_record.go
index 9b75ab5..244a821 100644
--- a/vendor/github.com/Shopify/sarama/control_record.go
+++ b/vendor/github.com/Shopify/sarama/control_record.go
@@ -1,14 +1,14 @@
package sarama
-//ControlRecordType ...
+// ControlRecordType ...
type ControlRecordType int
const (
- //ControlRecordAbort is a control record for abort
+ // ControlRecordAbort is a control record for abort
ControlRecordAbort ControlRecordType = iota
- //ControlRecordCommit is a control record for commit
+ // ControlRecordCommit is a control record for commit
ControlRecordCommit
- //ControlRecordUnknown is a control record of unknown type
+ // ControlRecordUnknown is a control record of unknown type
ControlRecordUnknown
)
@@ -23,16 +23,6 @@
func (cr *ControlRecord) decode(key, value packetDecoder) error {
var err error
- cr.Version, err = value.getInt16()
- if err != nil {
- return err
- }
-
- cr.CoordinatorEpoch, err = value.getInt32()
- if err != nil {
- return err
- }
-
// There a version for the value part AND the key part. And I have no idea if they are supposed to match or not
// Either way, all these version can only be 0 for now
cr.Version, err = key.getInt16()
@@ -55,6 +45,18 @@
// UNKNOWN is used to indicate a control type which the client is not aware of and should be ignored
cr.Type = ControlRecordUnknown
}
+ // we want to parse value only if we are decoding control record of known type
+ if cr.Type != ControlRecordUnknown {
+ cr.Version, err = value.getInt16()
+ if err != nil {
+ return err
+ }
+
+ cr.CoordinatorEpoch, err = value.getInt32()
+ if err != nil {
+ return err
+ }
+ }
return nil
}