aboutsummaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorNathanial Woolls <nathanial.woolls@idmworks.com>2017-05-17 13:00:24 -0400
committerNathanial Woolls <nathanial.woolls@idmworks.com>2017-05-17 13:00:24 -0400
commitee9f820ef54427a0eadc44f4e8f0d1d6e2f44ef0 (patch)
treee758a8aa3e08d45b14eaa3617be794668fef7a27 /src/main/java
parentbca993a7cabdf6501bcf08438892b8e4d63d37c3 (diff)
downloadbbprb-ee9f820ef54427a0eadc44f4e8f0d1d6e2f44ef0.tar.gz
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
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketRepository.java25
1 files changed, 21 insertions, 4 deletions
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()
);