Skip to content

Commit

Permalink
fix(protocol): fix type assertion error
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
3 people authored Jul 10, 2022
1 parent eeb9d56 commit 394527d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion protocol/listgroups/listgroups.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ func (r *Response) Merge(requests []protocol.Message, results []interface{}) (
response := &Response{}

for r, result := range results {
brokerResp := result.(*Response)
m, err := protocol.Result(result)
if err != nil {
return nil, err
}
brokerResp := m.(*Response)
respGroups := []ResponseGroup{}

for _, brokerResp := range brokerResp.Groups {
Expand Down
2 changes: 1 addition & 1 deletion protocol/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ type Merger interface {
Merge(messages []Message, results []interface{}) (Message, error)
}

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

0 comments on commit 394527d

Please sign in to comment.