diff options
author | Martin Damovsky <martin.damovsky@gmail.com> | 2017-09-01 16:51:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-01 16:51:32 +0200 |
commit | 92cf04a50b051cb6c96d0000eb8763797b239496 (patch) | |
tree | 044dcf781e4d5094f5ca07bf8cbb85eb95263c80 /src | |
parent | 2a767254d838c339cd8856648b4edbc410189a30 (diff) | |
parent | ee9994e91c5aad01c754250c16b890b583d3b8b2 (diff) | |
download | bbprb-92cf04a50b051cb6c96d0000eb8763797b239496.tar.gz |
Merge pull request #126 from sazo/master
Improved logging for thoubleshooting and fixed NullpointerException
Diffstat (limited to 'src')
3 files changed, 10 insertions, 3 deletions
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuilds.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuilds.java index 216287d..6ba3dab 100644 --- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuilds.java +++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketBuilds.java @@ -19,6 +19,7 @@ public class BitbucketBuilds { public BitbucketBuilds(BitbucketBuildTrigger trigger, BitbucketRepository repository) { this.trigger = trigger; this.repository = repository; + this.repository.init(); } void onStarted(BitbucketCause cause, Run<?, ?> build) { diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketPullRequestsBuilder.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketPullRequestsBuilder.java index 4474581..5b37fea 100644 --- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketPullRequestsBuilder.java +++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/BitbucketPullRequestsBuilder.java @@ -43,6 +43,7 @@ public class BitbucketPullRequestsBuilder { throw new IllegalStateException(); } this.repository = new BitbucketRepository(this.trigger.getProjectPath(), this); + this.repository.init(); this.builds = new BitbucketBuilds(this.trigger, this.repository); return this; } diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java index cb14908..0c21806 100644 --- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java +++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java @@ -142,7 +142,8 @@ public class ApiClient { public boolean hasBuildStatus(String owner, String repositoryName, String revision, String keyEx) { String url = v2(owner, repositoryName, "/commit/" + revision + "/statuses/build/" + this.computeAPIKey(keyEx)); - return get(url).contains("\"state\""); + String reqBody = get(url); + return reqBody != null && reqBody.contains("\"state\""); } public void setBuildStatus(String owner, String repositoryName, String revision, BuildState state, String buildUrl, String comment, String keyEx) { @@ -256,8 +257,12 @@ public class ApiClient { client.getState().setCredentials(AuthScope.ANY, credentials); client.getParams().setAuthenticationPreemptive(true); try { - client.executeMethod(req); - return req.getResponseBodyAsString(); + int statusCode = client.executeMethod(req); + if (statusCode != HttpStatus.SC_OK) { + logger.log(Level.WARNING, "Response status: " + req.getStatusLine()+" URI: "+req.getURI()); + }else{ + return req.getResponseBodyAsString(); + } } catch (HttpException e) { logger.log(Level.WARNING, "Failed to send request.", e); } catch (IOException e) { |