From ee9994e91c5aad01c754250c16b890b583d3b8b2 Mon Sep 17 00:00:00 2001 From: Daniel Fly Date: Mon, 26 Jun 2017 13:59:50 +0200 Subject: Fixed NPE --- .../bitbucketpullrequestbuilder/bitbucket/ApiClient.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/ApiClient.java index cf3675c..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) { @@ -258,7 +259,7 @@ public class ApiClient { try { int statusCode = client.executeMethod(req); if (statusCode != HttpStatus.SC_OK) { - logger.log(Level.WARNING, "Response code failed: " + req.getStatusLine()); + logger.log(Level.WARNING, "Response status: " + req.getStatusLine()+" URI: "+req.getURI()); }else{ return req.getResponseBodyAsString(); } -- cgit v1.2.3