Skip to content
This repository has been archived by the owner on Jun 9, 2021. It is now read-only.

Commit

Permalink
Avoiding trying to read empty responses from notifications #194
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Feb 1, 2017
1 parent 6b8832e commit 12f2257
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 10 additions & 7 deletions src/main/java/se/bjurr/prnfb/http/UrlInvoker.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.<br>
* <br>
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 12f2257

Please sign in to comment.