Check for null result of getFixVersion#661
Check for null result of getFixVersion#661davedevretro wants to merge 4 commits intojenkinsci:masterfrom
Conversation
|
Thanks for the contribution! I see you have checked |
|
Sorry I thought this meant that I was confirming it was tested - unticked now. |
rantoniuk
left a comment
There was a problem hiding this comment.
Build fails because of format check failure.
You need to run mvn spotless:apply after all changes, before committing changes
|
|
||
| Iterable<Version> versions = issue.getFixVersions(); | ||
| if(versions != null) { | ||
| for (Version currentVersion : versions) { |
There was a problem hiding this comment.
How about using ListUtils.emptyIfNull() instead of adding the if clause?
There was a problem hiding this comment.
Scratch that, we're stuck on version 3 for now, that doesn't have this.
There was a problem hiding this comment.
Found another way using Java8 Optional:
for (Version currentVersion : Optional.ofNullable(issue.getFixVersions()).orElse(Collections.emptyList())) {There was a problem hiding this comment.
Is it starting to break readability for minimal gain at this point?
There was a problem hiding this comment.
I think it looks cleaner than adding another nested if statement, especially when there is no else (maybe we should consider adding LOGGING.fine()) , but it's fine if you want to leave it as it is.
Would you be able to add a test for this? I think this should be pretty easy by mocking the Null response object.
There was a problem hiding this comment.
Couldn't work out how to get a unit test to work for this case - sorry.. :/
|
updated formatting |
bed3adb to
85113ab
Compare
Issue #658
Check for null result of getFixVersions as per example on atlassian site:
https://developer.atlassian.com/server/jira/platform/creating-workflow-extensions/#step-2.-edit-the-code
Tested on my local Jenkins instance.
🚨 Please review the guidelines for contributing to this repository.