From ee9f820ef54427a0eadc44f4e8f0d1d6e2f44ef0 Mon Sep 17 00:00:00 2001 From: Nathanial Woolls Date: Wed, 17 May 2017 13:00:24 -0400 Subject: Fix NullPointerException when a Pull Request's destination commit is NULL * see: https://github.com/nishio-dens/bitbucket-pullrequest-builder-plugin/issues/119 * see: https://github.com/nishio-dens/bitbucket-pullrequest-builder-plugin/issues/98 --- .../BitbucketRepository.java | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'src/main') diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java index 02d11c5..352ec04 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() ); -- cgit v1.2.3 From 5dbd62e5d66ebb577ab51b2cbecb9b7d4439c6d8 Mon Sep 17 00:00:00 2001 From: Nathanial Woolls Date: Wed, 17 May 2017 13:06:19 -0400 Subject: Fix error executing javadoc target - An error has occurred in JavaDocs report generation: error: unexpected text --- .../bitbucketpullrequestbuilder/bitbucket/BuildState.java | 2 +- .../bitbucketpullrequestbuilder/bitbucket/Pullrequest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main') 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) -- cgit v1.2.3