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

rpc: correctly check for nil before cast #100296

Merged
merged 1 commit into from
Mar 31, 2023

Conversation

andrewbaptist
Copy link
Collaborator

As part of the fix of #99104, a cast without a nil check was introduced. This PR addresses that by only casting if it is known to be not nil.

Epic: none
Fixes: #100275
Release note: None

@andrewbaptist andrewbaptist requested a review from a team as a code owner March 31, 2023 12:56
@blathers-crl
Copy link

blathers-crl bot commented Mar 31, 2023

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Contributor

@ajwerner ajwerner left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -2715,13 +2715,14 @@ func (rpcCtx *Context) loadOrCreateConnAttempt(
select {
case <-previousAttempt.initialHeartbeatDone:
// The connection attempt was completed, return the outcome of it.
err := previousAttempt.err.Load().(error)
Copy link
Contributor

Choose a reason for hiding this comment

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

slight preference for just changing this to err, _ := previousAttempt.err.Load().(error), but only slight. This could still panic if somehow err.Load() had a non-nil, non-error value

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

changed

As part of the fix of cockroachdb#99104, a cast without a nil check was introduced.
This PR addresses that by only casting if it is known to be not nil.

Epic: none
Fixes: cockroachdb#100275
Release note: None
@andrewbaptist
Copy link
Collaborator Author

bors r=ajwerner

@craig
Copy link
Contributor

craig bot commented Mar 31, 2023

Build succeeded:

@craig craig bot merged commit dcac33e into cockroachdb:master Mar 31, 2023
@knz
Copy link
Contributor

knz commented Apr 2, 2023

does this need to be backported?

@erikgrinaker
Copy link
Contributor

It's included in #100238, the backport of the original change.

@andrewbaptist andrewbaptist deleted the 2023-03-30-fix-error branch December 15, 2023 21:34
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.

kv/kvserver/reports: TestReplicationStatusReportIntegration failed
5 participants