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

NPE when getting version when there is no build date #3047

Closed
yevgenykuz opened this issue Apr 26, 2021 · 2 comments · Fixed by #3049
Closed

NPE when getting version when there is no build date #3047

yevgenykuz opened this issue Apr 26, 2021 · 2 comments · Fixed by #3049

Comments

@yevgenykuz
Copy link
Contributor

The fetchVersion() method will fail with NPE when the API server doesn't return the build date.

It happens because SimpleDateFormat can't parse null values.

A possible fix can be null checking before calling buildWithDate:

return new VersionInfo.Builder().withBuildDate(responseAsMap.get(VersionInfo.VersionKeys.BUILD_DATE))

Or within the buildWithDate function itself if a default value should be provided:

public Builder withBuildDate(String buildDate) throws ParseException {

This can be reproduced if k8s is mocked with the provided server in CRUD mode - https://github.com/fabric8io/kubernetes-client#crud-mode

@rohanKanojia
Copy link
Member

@yevgenykuz : Thanks for reporting this! Would appreciate it if you could create a PR. What default value do you think we'll provide?

@yevgenykuz
Copy link
Contributor Author

NP Ill open a PR later this week.
Not sure about the default value, i'd write "N/A" but it requires changing the type to String. I prefer to change as little as possible since i didn't go over the code to see what else may be affected.

manusa pushed a commit that referenced this issue Apr 30, 2021
* Add null check for build date before trying to parse it.

Signed-off-by: Yevgeny Kuznetsov <yevgenyku@gmail.com>
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 a pull request may close this issue.

2 participants