Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(protocol): fix type assertion error #931

Merged
merged 12 commits into from Jul 10, 2022
Merged

fix(protocol): fix type assertion error #931

merged 12 commits into from Jul 10, 2022

Conversation

kscooo
Copy link
Contributor

@kscooo kscooo commented Jun 14, 2022

In the event of a sudden network outage (such as a sudden wifi disconnection or vpn request to reconnect), the ListGroups method panics because the result is incorrectly asserted as Response, but is actually an error type (e.g. context deadline exceeded or *net.OpError etc)

ksco.he added 2 commits June 14, 2022 17:08
The `ListGroups` method will panic if the network is interrupted.
@@ -57,8 +59,15 @@ func (r *Response) Merge(requests []protocol.Message, results []interface{}) (
response := &Response{}

for r, result := range results {
brokerResp := result.(*Response)
respGroups := []ResponseGroup{}
brokerResp, ok := result.(*Response)
Copy link
Contributor

@nlsun nlsun Jul 1, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kscooo good catch! What do you think about modeling your bug fix after this one?

m, err := protocol.Result(res)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forgive me for not knowing the rest of the source code for this project, it looks like this fix is much better

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem! The protocol package ("github.com/segmentio/kafka-go/protocol") already has an implementation of the Result function though, do you think you could use that instead of redefining it in this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed, sorry for not noticing that the *Response implements Message interface

Copy link
Contributor

@nlsun nlsun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some tweaks

protocol/listgroups/listgroups.go Outdated Show resolved Hide resolved
protocol/listgroups/listgroups.go Outdated Show resolved Hide resolved
@nlsun nlsun merged commit 394527d into segmentio:main Jul 10, 2022
@nlsun
Copy link
Contributor

nlsun commented Jul 10, 2022

Thanks for the fix!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants