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

Safely checks read ring for potentially nil scheduler #4525

Merged
merged 1 commit into from
Oct 22, 2021

Conversation

owen-d
Copy link
Member

@owen-d owen-d commented Oct 22, 2021

Previously the method signature was (s *Scheduler) SafeReadRing() which checks if s == nil ||. Notably, this can never execute because calling a method on a nil pointer will panic. This fix likely prevents panics when running in microservices mode where the scheduler is not instantiated.

Edit: I stand corrected https://play.golang.org/p/-OfmuRO-Q8f

@owen-d owen-d requested a review from a team as a code owner October 22, 2021 12:31
Copy link
Collaborator

@slim-bean slim-bean left a comment

Choose a reason for hiding this comment

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

Yeah this kind of blew my mind, but I think this solution feels safer and cleaner so I think we should merge it.

@owen-d owen-d merged commit aec00c2 into grafana:main Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants