Skip to content

Commit 394527d

Browse files
kscoooksco.henlsun
authored
fix(protocol): fix type assertion error
The `ListGroups` method will panic if the network is interrupted. Co-authored-by: ksco.he <ksco.he@ponyft.com> Co-authored-by: Nicholas Sun <olassun2@gmail.com>
1 parent eeb9d56 commit 394527d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

protocol/listgroups/listgroups.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,11 @@ func (r *Response) Merge(requests []protocol.Message, results []interface{}) (
5757
response := &Response{}
5858

5959
for r, result := range results {
60-
brokerResp := result.(*Response)
60+
m, err := protocol.Result(result)
61+
if err != nil {
62+
return nil, err
63+
}
64+
brokerResp := m.(*Response)
6165
respGroups := []ResponseGroup{}
6266

6367
for _, brokerResp := range brokerResp.Groups {

protocol/protocol.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ type Merger interface {
492492
Merge(messages []Message, results []interface{}) (Message, error)
493493
}
494494

495-
// Result converts r to a Message or and error, or panics if r could be be
495+
// Result converts r to a Message or an error, or panics if r could not be
496496
// converted to these types.
497497
func Result(r interface{}) (Message, error) {
498498
switch v := r.(type) {

0 commit comments

Comments
 (0)