-
Notifications
You must be signed in to change notification settings - Fork 56
fix NPE for build waiter #640
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -832,7 +832,11 @@ public Build getBuild(String name) { | |||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| public Build getLatestBuild(String buildConfigName) { | ||||||||||||||||||
| long lastVersion = buildConfigs().withName(buildConfigName).get().getStatus().getLastVersion(); | ||||||||||||||||||
| BuildConfig bc = buildConfigs().withName(buildConfigName).get(); | ||||||||||||||||||
| if (bc == null) { | ||||||||||||||||||
| return null; | ||||||||||||||||||
| } | ||||||||||||||||||
| long lastVersion = bc.getStatus().getLastVersion(); | ||||||||||||||||||
|
||||||||||||||||||
| long lastVersion = bc.getStatus().getLastVersion(); | |
| if (bc.getStatus() == null) { | |
| return null; | |
| } | |
| Long lastVersion = bc.getStatus().getLastVersion(); | |
| if (lastVersion == null || lastVersion == 0L) { | |
| return null; | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): Guard against a null BuildConfig status before calling getLastVersion()
The null check on
bcprevents one NPE, butbc.getStatus()itself can still be null (e.g., for a newly created/partially initialized BuildConfig), causing an NPE ongetStatus().getLastVersion(). Please also guard against a null status (and optionally handle a 0/unsetgetLastVersion()) before building the name, or fail in a controlled way.