Skip to content

rpc: correctly check for nil before cast#100296

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
andrewbaptist:2023-03-30-fix-error
Mar 31, 2023
Merged

rpc: correctly check for nil before cast#100296
craig[bot] merged 1 commit intocockroachdb:masterfrom
andrewbaptist:2023-03-30-fix-error

Conversation

@andrewbaptist
Copy link
Copy Markdown

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
Copy Markdown

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
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
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

select {
case <-previousAttempt.initialHeartbeatDone:
// The connection attempt was completed, return the outcome of it.
err := previousAttempt.err.Load().(error)
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Author

bors r=ajwerner

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Mar 31, 2023

Build succeeded:

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

knz commented Apr 2, 2023

does this need to be backported?

@erikgrinaker
Copy link
Copy Markdown
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