diff --git a/CHANGELOG.md b/CHANGELOG.md index b506c283..56cf777c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,12 @@ Changelog of Pull Request Notifier for Bitbucket. * PULL_REQUEST_REVIEWERS_NEEDS_WORK_EMAIL * PULL_REQUEST_REVIEWERS_NEEDS_WORK_NAME - [72607d4617b0e7d](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/72607d4617b0e7d) Tomas Bjerre *2017-02-01 19:16:26* + [6b8832e587d55b0](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/6b8832e587d55b0) Tomas Bjerre *2017-02-01 19:23:38* + +### GitHub [#194](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/issues/194) Pull Request activity throws IllegalArgumentException + Avoiding trying to read empty responses from notifications + + [6723e59c0b892d0](https://github.com/tomasbjerre/pull-request-notifier-for-bitbucket/commit/6723e59c0b892d0) Tomas Bjerre *2017-02-01 19:29:09* ### No issue doc diff --git a/src/main/java/se/bjurr/prnfb/http/UrlInvoker.java b/src/main/java/se/bjurr/prnfb/http/UrlInvoker.java index 90b715f4..19e1621d 100644 --- a/src/main/java/se/bjurr/prnfb/http/UrlInvoker.java +++ b/src/main/java/se/bjurr/prnfb/http/UrlInvoker.java @@ -46,12 +46,12 @@ import org.apache.http.util.EntityUtils; import org.slf4j.Logger; -import se.bjurr.prnfb.settings.PrnfbHeader; -import se.bjurr.prnfb.settings.PrnfbNotification; - import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Optional; +import se.bjurr.prnfb.settings.PrnfbHeader; +import se.bjurr.prnfb.settings.PrnfbNotification; + /** * If told to accept all certificates, an unsafe X509 trust manager is used.
*
@@ -352,10 +352,13 @@ HttpResponse doInvoke(HttpRequestBase httpRequestBase, HttpClientBuilder builder .execute(httpRequestBase); HttpEntity entity = httpResponse.getEntity(); - return new HttpResponse( - httpRequestBase.getURI(), - httpResponse.getStatusLine().getStatusCode(), - EntityUtils.toString(entity, UTF_8)); + String entityString = ""; + if (entity != null) { + entityString = EntityUtils.toString(entity, UTF_8); + } + URI uri = httpRequestBase.getURI(); + int statusCode = httpResponse.getStatusLine().getStatusCode(); + return new HttpResponse(uri, statusCode, entityString); } catch (final Exception e) { LOG.error("", e); } finally {