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: Fix npe for propagation url settings #340

Merged

Conversation

solarlodge
Copy link
Contributor

@solarlodge solarlodge commented Sep 19, 2024

When upgrading from older versions of the plugin the propagationUrl tag might be missing in
io.jenkins.plugins.bitbucketpushandpullrequest.config.BitBucketPPRPluginConfig.xml. Since propagationUrl's value is checked for emptiness only this might result in a NPE with error message:

java.lang.NullPointerException: Cannot invoke "String.isEmpty()" because the return value of "io.jenkins.plugins.bitbucketpushandpullrequest.config.BitBucketPPRPluginConfig.getPropagationUrl()" is null

This commit adds a check for null+emptiness.

The issue can be reproduced easily by deleting the propagationUrl tag from the given config file, reload and try to trigger a build via webhook.
You can then either enter a whitespace in the config field for propagationUrl and delete it afterwards or enter the line <propagationUrl></propagationUrl> into the config file directly. This will prevent throwing a NPE too.

Testing done

I provided my fix, built a hpi file and installed it to a testinstance over the old 3.0.3 of the plugin.
I made sure io.jenkins.plugins.bitbucketpushandpullrequest.config.BitBucketPPRPluginConfig.xml was lacking the propagationUrl tag.
I could ensure that afterwards:

  • I could trigger a build without the tag
  • The functionality of the propagationUrl was still present when configured properly

Submitter checklist

  • Make sure you are opening from a topic/feature/bugfix branch (right side) and not your main branch!
  • Ensure that the pull request title represents the desired changelog entry
  • Please describe what you did
  • Ensure you have provided tests - that demonstrates feature works or fixes the issue

@julioc-p julioc-p self-requested a review September 19, 2024 08:50
@julioc-p
Copy link
Collaborator

Hi! Thanks for the PR. Here are some comments from my side:

  1. There are some tests failing.
  2. There are not new tests for this
  3. This also has to be added for the BitBucketPPRServerRepositoryAction file.

Let me know if I can help!

When upgrading from older versions of the plugin the propagationUrl tag
might be missing in
io.jenkins.plugins.bitbucketpushandpullrequest.config.BitBucketPPRPluginConfig.xml.
Since propagationUrl's value is checked for emptiness only this might
result in a NPE. This commit adds a check for null+emptiness.
@solarlodge solarlodge force-pushed the fix/fix-npe-for-propagation-url-settings branch from f8b71bc to fbcc48b Compare September 19, 2024 13:29
Copy link
Collaborator

@julioc-p julioc-p left a comment

Choose a reason for hiding this comment

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

LGTM

@julioc-p julioc-p merged commit ba4090f into jenkinsci:master Sep 19, 2024
17 of 18 checks passed
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.

2 participants