Skip to content

Commit

Permalink
Merge pull request #340 from solarlodge/fix/fix-npe-for-propagation-u…
Browse files Browse the repository at this point in the history
…rl-settings

Fix: Fix npe for propagation url settings
  • Loading branch information
julioc-p authored Sep 19, 2024
2 parents bcc10b8 + fbcc48b commit ba4090f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
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()) {
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public void testBaseUrlSet() {
BitBucketPPRPluginConfig.class)) {
BitBucketPPRPluginConfig c = mock(BitBucketPPRPluginConfig.class);
config.when(BitBucketPPRPluginConfig::getInstance).thenReturn(c);
when(c.isPropagationUrlSet()).thenReturn(true);
when(c.getPropagationUrl()).thenReturn("https://example.org/scm/some-namespace/some-repo.git");

BitBucketPPRPayload payloadMock = mock(BitBucketPPRPayload.class, RETURNS_DEEP_STUBS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public void testProcessPayload() throws Exception {
Mockito.mockStatic(BitBucketPPRPluginConfig.class)) {
BitBucketPPRPluginConfig c = mock(BitBucketPPRPluginConfig.class);
config.when(BitBucketPPRPluginConfig::getInstance).thenReturn(c);
when(c.getPropagationUrl()).thenReturn("");

BitBucketPPRJobProbe probe = mock(BitBucketPPRJobProbe.class);

Expand Down

0 comments on commit ba4090f

Please sign in to comment.