Skip to content

Commit

Permalink
Fix: Fix npe for propagation url settings
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
solarlodge committed Sep 19, 2024
1 parent bcc10b8 commit f8b71bc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public BitBucketPPRPullRequestServerAction(@Nonnull BitBucketPPRPayload payload)
}
}

if (!globalConfig.getPropagationUrl().isEmpty()) {
if (globalConfig.isPropagationUrlSet()) {

Check warning on line 91 in src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/action/BitBucketPPRPullRequestServerAction.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Partially covered line

Line 91 is only partially covered, one branch is missing
try {
this.baseUrl = new URL(globalConfig.getPropagationUrl());
} catch (MalformedURLException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ public String getPropagationUrl() {
return propagationUrl;
}

public boolean isPropagationUrlSet() {
return !isEmpty(propagationUrl);

Check warning on line 105 in src/main/java/io/jenkins/plugins/bitbucketpushandpullrequest/config/BitBucketPPRPluginConfig.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered line

Line 105 is not covered by tests
}

@DataBoundSetter
public void setNotifyBitBucket(@CheckForNull boolean notifyBitBucket) {
this.notifyBitBucket = notifyBitBucket;
Expand Down

0 comments on commit f8b71bc

Please sign in to comment.