Skip to content

Commit bfaa60f

Browse files
authored
Merge pull request #1051 from buyology/no-rack-on-find-coordinator-response
remove rack from FindCoordinatorResponse
2 parents 1995278 + 5a23d49 commit bfaa60f

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

find_coordinator_response.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ func (f *FindCoordinatorResponse) decode(pd packetDecoder, version int16) (err e
3838
}
3939

4040
coordinator := new(Broker)
41-
if err := coordinator.decode(pd, version); err != nil {
41+
// The version is hardcoded to 0, as version 1 of the Broker-decode
42+
// contains the rack-field which is not present in the FindCoordinatorResponse.
43+
if err := coordinator.decode(pd, 0); err != nil {
4244
return err
4345
}
4446
if coordinator.addr == ":0" {
@@ -66,7 +68,7 @@ func (f *FindCoordinatorResponse) encode(pe packetEncoder) error {
6668
if coordinator == nil {
6769
coordinator = NoNode
6870
}
69-
if err := coordinator.encode(pe, f.Version); err != nil {
71+
if err := coordinator.encode(pe, 0); err != nil {
7072
return err
7173
}
7274
return nil

find_coordinator_response_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77

88
func TestFindCoordinatorResponse(t *testing.T) {
99
errMsg := "kaboom"
10-
brokerRack := "foo"
1110

1211
for _, tc := range []struct {
1312
desc string
@@ -38,7 +37,6 @@ func TestFindCoordinatorResponse(t *testing.T) {
3837
Coordinator: &Broker{
3938
id: 7,
4039
addr: "host:9092",
41-
rack: &brokerRack,
4240
},
4341
},
4442
encoded: []byte{
@@ -48,7 +46,6 @@ func TestFindCoordinatorResponse(t *testing.T) {
4846
0, 0, 0, 7, // Coordinator.ID
4947
0, 4, 'h', 'o', 's', 't', // Coordinator.Host
5048
0, 0, 35, 132, // Coordinator.Port
51-
0, 3, 'f', 'o', 'o', // Coordinator.Rack
5249
},
5350
}, {
5451
desc: "version 0 - error",
@@ -79,7 +76,6 @@ func TestFindCoordinatorResponse(t *testing.T) {
7976
255, 255, 255, 255, // Coordinator.ID: -1
8077
0, 0, // Coordinator.Host: ""
8178
255, 255, 255, 255, // Coordinator.Port: -1
82-
255, 255, // Coordinator.Rack: empty
8379
},
8480
}} {
8581
testResponse(t, tc.desc, tc.response, tc.encoded)

0 commit comments

Comments
 (0)