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(serviceref): guard against nulls #700

Merged
merged 3 commits into from
Oct 5, 2021

Conversation

andrewazores
Copy link
Member

Fixes #699

From various readings, it seems that the obj.metadata field is always present, but the labels and annotations properties may not always be (but "should"). Here I add guards within the ServiceRef methods to treat null labels/annotations as if they are empty Maps to avoid NPEs in cases where platform implementations may return nulls to us.

https://kubernetes.io/docs/reference/kubernetes-api/workload-resources/pod-v1/
https://kubernetes.io/docs/concepts/overview/working-with-objects/kubernetes-objects/
https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#metadata

Copy link
Member

@ebaron ebaron left a comment

Choose a reason for hiding this comment

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

Tested in Minikube and it works fine now. Thanks!

@ebaron ebaron merged commit 24aff86 into cryostatio:main Oct 5, 2021
mergify bot pushed a commit that referenced this pull request Oct 5, 2021
* fix(serviceref): guard against nulls

* test(serviceref): add unit tests

* chore(serviceref): apply spotless formatting

(cherry picked from commit 24aff86)
ebaron pushed a commit that referenced this pull request Oct 5, 2021
* fix(serviceref): guard against nulls

* test(serviceref): add unit tests

* chore(serviceref): apply spotless formatting

(cherry picked from commit 24aff86)

Co-authored-by: Andrew Azores <aazores@redhat.com>
@andrewazores andrewazores deleted the npe-serviceref branch October 5, 2021 18:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NPE building ServiceRef
2 participants