Skip to content

Commit

Permalink
fix metadata requests version 1
Browse files Browse the repository at this point in the history
Handle topic array length when it's -1
And adds some fields to the metadata response

closes travisjeffery#159
  • Loading branch information
snichme authored and alekitto committed Jun 26, 2020
1 parent b1b65b4 commit 47faa69
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions protocol/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@ func (d *ByteDecoder) StringArray() ([]string, error) {
d.off = len(d.b)
return nil, ErrInsufficientData
}
n := int(Encoding.Uint32(d.b[d.off:]))
n := int32(Encoding.Uint32(d.b[d.off:]))
d.off += 4

if n == 0 {
if n == 0 || n == -1 {
return nil, nil
}

Expand Down
2 changes: 2 additions & 0 deletions protocol/metadata_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func (r *MetadataResponse) Encode(e PacketEncoder) (err error) {
return err
}
e.PutInt32(b.Port)
e.PutString("")
}
if r.APIVersion >= 1 {
e.PutInt32(r.ControllerID)
Expand All @@ -51,6 +52,7 @@ func (r *MetadataResponse) Encode(e PacketEncoder) (err error) {
if err = e.PutString(t.Topic); err != nil {
return err
}
e.PutInt8(0)
if err = e.PutArrayLength(len(t.PartitionMetadata)); err != nil {
return err
}
Expand Down

0 comments on commit 47faa69

Please sign in to comment.