aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorMartin Damovsky <martin.damovsky@gmail.com>2017-06-04 21:33:29 +0200
committerGitHub <noreply@github.com>2017-06-04 21:33:29 +0200
commit5b86923fba465f914ed0f9da6393b9ae9e22287d (patch)
treee36e88b923d5cf33328f208c21f501aceab38295 /src/main/java
parent799209b435e1db4111f1ed570be0b97dc5dd11a9 (diff)
parent5dbd62e5d66ebb577ab51b2cbecb9b7d4439c6d8 (diff)
downloadbbprb-5b86923fba465f914ed0f9da6393b9ae9e22287d.tar.gz
Merge pull request #122 from IDMWORKS/bug/null-destination-commit
Fix NullPointerException when a Pull Request's destination commit is NULL
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java25
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BuildState.java2
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/Pullrequest.java2
3 files changed, 23 insertions, 6 deletions
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java
index 2bf320b..3b0a314 100644
--- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java
+++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java
@@ -291,17 +291,34 @@ public class BitbucketRepository {
}
private boolean isFilteredBuild(Pullrequest pullRequest) {
+
+ final String pullRequestId = pullRequest.getId();
+ final String pullRequestTitle = pullRequest.getTitle();
+ final String destinationRepoName = pullRequest.getDestination().getRepository().getRepositoryName();
+
+ // pullRequest.getDestination().getCommit() may return null for pull requests with merge conflicts
+ // * see: https://github.com/nishio-dens/bitbucket-pullrequest-builder-plugin/issues/119
+ // * see: https://github.com/nishio-dens/bitbucket-pullrequest-builder-plugin/issues/98
+ final String destinationCommitHash;
+ if (pullRequest.getDestination().getCommit() == null) {
+ logger.log(Level.INFO, "Pull request #{0} ''{1}'' in repo ''{2}'' has a null value for destination commit.",
+ new Object[]{pullRequestId, pullRequestTitle, destinationRepoName});
+ destinationCommitHash = null;
+ } else {
+ destinationCommitHash = pullRequest.getDestination().getCommit().getHash();
+ }
+
BitbucketCause cause = new BitbucketCause(
pullRequest.getSource().getBranch().getName(),
pullRequest.getDestination().getBranch().getName(),
pullRequest.getSource().getRepository().getOwnerName(),
pullRequest.getSource().getRepository().getRepositoryName(),
- pullRequest.getId(),
+ pullRequestId,
pullRequest.getDestination().getRepository().getOwnerName(),
- pullRequest.getDestination().getRepository().getRepositoryName(),
- pullRequest.getTitle(),
+ destinationRepoName,
+ pullRequestTitle,
pullRequest.getSource().getCommit().getHash(),
- pullRequest.getDestination().getCommit().getHash(),
+ destinationCommitHash,
pullRequest.getAuthor().getCombinedUsername()
);
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BuildState.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BuildState.java
index e5c15ef..a3ef1f1 100644
--- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BuildState.java
+++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BuildState.java
@@ -3,7 +3,7 @@ package bitbucketpullrequestbuilder.bitbucketpullrequestbuilder.bitbucket;
/**
* Valid build states for a pull request
*
- * @see https://confluence.atlassian.com/bitbucket/buildstatus-resource-779295267.html
+ * @see "https://confluence.atlassian.com/bitbucket/buildstatus-resource-779295267.html"
*/
public enum BuildState {
FAILED, INPROGRESS, SUCCESSFUL
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/Pullrequest.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/Pullrequest.java
index 7ccad7d..b69805e 100644
--- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/Pullrequest.java
+++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/Pullrequest.java
@@ -11,7 +11,7 @@ import org.codehaus.jackson.annotate.JsonProperty;
* POJOs representing the pull-requests extracted from the
* JSON response of the Bitbucket API V2.
*
- * @see https://confluence.atlassian.com/bitbucket/pullrequests-resource-423626332.html#pullrequestsResource-GETaspecificpullrequest
+ * @see "https://confluence.atlassian.com/bitbucket/pullrequests-resource-423626332.html#pullrequestsResource-GETaspecificpullrequest"
*/
@JsonIgnoreProperties(ignoreUnknown = true)