-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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 possible nil before casting #5017
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@easwars it looks like you originally wrote this - what do you think?
@@ -560,6 +560,9 @@ func TestClusterManagerForwardsBalancerBuildOptions(t *testing.T) { | |||
ctx, cancel := context.WithTimeout(context.Background(), defaultTestTimeout) | |||
defer cancel() | |||
if v, err := ccsCh.Receive(ctx); err != nil { | |||
if v == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this actually a guarantee here?
I think this is written incorrectly, because it's not actually validating v
at all in the normal case (where there is no timeout). Probably what was meant was:
v, err := ccsCh.Receive(ctx)
if err != nil {
t.Fatalf("timed out waiting for UpdateClientConnState result: %v", err)
}
if v != nil {
t.Fatal(v)
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes. We need to check err first.
Yup, good catch and fix I think. |
This PR aims to fix a possible nil before casting to error.
RELEASE NOTES: none