Skip to content

use JenkinsLocationConfiguration.get()#9

Merged
jovandeginste merged 1 commit intojenkinsci:masterfrom
dodgex:fix_notification_url
Jan 16, 2019
Merged

use JenkinsLocationConfiguration.get()#9
jovandeginste merged 1 commit intojenkinsci:masterfrom
dodgex:fix_notification_url

Conversation

@dodgex
Copy link

@dodgex dodgex commented Jan 8, 2019

instead of new JenkinsLocationConfiguration()

Trying to fix: https://issues.jenkins-ci.org/browse/JENKINS-54054

Inspired by: jenkinsci/stash-pullrequest-builder-plugin#26

@jovandeginste
Copy link

@dodgex thanks for the PR - I will be running your PR in my setup for a few days

@furai
Copy link

furai commented Jan 13, 2019

Nicely done. I'll probably use it as well, unless it gets merged upstream pretty soon.

@jovandeginste
Copy link

@furai Feel free to run it! I will try to merge and publish on Monday

@jovandeginste
Copy link

jovandeginste commented Jan 14, 2019

@dodgex While building the release, firebug complained about this:

    [INFO] <<< findbugs-maven-plugin:3.0.3:check (findbugs) < :findbugs @ mattermost <<<
    [INFO] 
    [INFO] --- findbugs-maven-plugin:3.0.3:check (findbugs) @ mattermost ---
    [INFO] BugInstance size is 2
    [INFO] Error size is 0
    [INFO] Total bugs: 2
    [INFO] Possible null pointer dereference in jenkins.plugins.mattermost.MattermostNotifier.getBuildServerUrl() due to return value of called method [jenkins.plugins.mattermost.MattermostNotifier, jenkins.plugins.mattermost.MattermostNotifier] Dereferenced at MattermostNotifier.java:[line 84]Known null at MattermostNotifier.java:[line 83] NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE
    [INFO] Possible null pointer dereference in jenkins.plugins.mattermost.MattermostNotifier$DescriptorImpl.getBuildServerUrl() due to return value of called method [jenkins.plugins.mattermost.MattermostNotifier$DescriptorImpl, jenkins.plugins.mattermost.MattermostNotifier$DescriptorImpl] Dereferenced at MattermostNotifier.java:[line 383]Known null at MattermostNotifier.java:[line 382] NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE
    [INFO] 

Would you mind adding a Null check?

@dodgex
Copy link
Author

dodgex commented Jan 14, 2019

I have added a new commit.

@jovandeginste
Copy link

@dodgex I added two comments as review

Copy link

@jovandeginste jovandeginste left a comment

Choose a reason for hiding this comment

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

see the inline comments

JenkinsLocationConfiguration jenkinsConfig = JenkinsLocationConfiguration.get();
return jenkinsConfig.getUrl();
String url = jenkinsConfig.getUrl();
if (url == null) {

Choose a reason for hiding this comment

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

@dodgex I think the test should be whether jenkinsConfig is null (and thus one line higher)

Choose a reason for hiding this comment

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

return (jenkinsConfig == null) ? null : jenkinsConfig.getUrl();

/ from the peanut gallery :)

Copy link
Author

Choose a reason for hiding this comment

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

sorry for the false check, i have checked the docs and it didnt seem that get() would return null and for getUrl() it has @CheckForNull...

JenkinsLocationConfiguration jenkinsConfig = JenkinsLocationConfiguration.get();
return jenkinsConfig.getUrl();
String url = jenkinsConfig.getUrl();
if (url == null) {

Choose a reason for hiding this comment

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

@dodgex same as my other comment

@jovandeginste
Copy link

FYI, you can test this by running mvn findbugs:check

@dodgex
Copy link
Author

dodgex commented Jan 15, 2019

PR is updated and changes have been squashed

@jovandeginste
Copy link

running the new version in our set-up now

@jovandeginste jovandeginste merged commit befb619 into jenkinsci:master Jan 16, 2019
@jovandeginste
Copy link

New release is coming your way!

@dodgex dodgex deleted the fix_notification_url branch January 16, 2019 10:47
@dodgex
Copy link
Author

dodgex commented Jan 16, 2019

Thank you for merging ! :)

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 this pull request may close these issues.

4 participants