Skip to content

Commit

Permalink
Merge pull request #1051 from buyology/no-rack-on-find-coordinator-re…
Browse files Browse the repository at this point in the history
…sponse

remove rack from FindCoordinatorResponse
  • Loading branch information
eapache committed Feb 14, 2018
2 parents 1995278 + 5a23d49 commit bfaa60f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 4 additions & 2 deletions find_coordinator_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ func (f *FindCoordinatorResponse) decode(pd packetDecoder, version int16) (err e
}

coordinator := new(Broker)
if err := coordinator.decode(pd, version); err != nil {
// The version is hardcoded to 0, as version 1 of the Broker-decode
// contains the rack-field which is not present in the FindCoordinatorResponse.
if err := coordinator.decode(pd, 0); err != nil {
return err
}
if coordinator.addr == ":0" {
Expand Down Expand Up @@ -66,7 +68,7 @@ func (f *FindCoordinatorResponse) encode(pe packetEncoder) error {
if coordinator == nil {
coordinator = NoNode
}
if err := coordinator.encode(pe, f.Version); err != nil {
if err := coordinator.encode(pe, 0); err != nil {
return err
}
return nil
Expand Down
4 changes: 0 additions & 4 deletions find_coordinator_response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

func TestFindCoordinatorResponse(t *testing.T) {
errMsg := "kaboom"
brokerRack := "foo"

for _, tc := range []struct {
desc string
Expand Down Expand Up @@ -38,7 +37,6 @@ func TestFindCoordinatorResponse(t *testing.T) {
Coordinator: &Broker{
id: 7,
addr: "host:9092",
rack: &brokerRack,
},
},
encoded: []byte{
Expand All @@ -48,7 +46,6 @@ func TestFindCoordinatorResponse(t *testing.T) {
0, 0, 0, 7, // Coordinator.ID
0, 4, 'h', 'o', 's', 't', // Coordinator.Host
0, 0, 35, 132, // Coordinator.Port
0, 3, 'f', 'o', 'o', // Coordinator.Rack
},
}, {
desc: "version 0 - error",
Expand Down Expand Up @@ -79,7 +76,6 @@ func TestFindCoordinatorResponse(t *testing.T) {
255, 255, 255, 255, // Coordinator.ID: -1
0, 0, // Coordinator.Host: ""
255, 255, 255, 255, // Coordinator.Port: -1
255, 255, // Coordinator.Rack: empty
},
}} {
testResponse(t, tc.desc, tc.response, tc.encoded)
Expand Down

0 comments on commit bfaa60f

Please sign in to comment.