Skip to content

Commit

Permalink
Merge pull request mapfish#492 from tsauerwein/http-cache-error
Browse files Browse the repository at this point in the history
Log errors if request fails in http cache
  • Loading branch information
Tobias Sauerwein authored Feb 7, 2017
2 parents 11ff0c6 + 32b3893 commit 35fb61b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,15 +139,19 @@ public ClientHttpResponse execute() throws IOException {
public Void call() throws Exception {
final String baseMetricName = HttpRequestCache.class.getName() + ".read." + getURI().getHost();
final Timer.Context timerDownload = HttpRequestCache.this.registry.timer(baseMetricName).time();
ClientHttpResponse originalResponse = this.originalRequest.execute();
ClientHttpResponse originalResponse = null;
try {
originalResponse = this.originalRequest.execute();
LOGGER.debug("Caching URI resource " + this.originalRequest.getURI());
this.response = new CachedClientHttpResponse(originalResponse);
} catch (IOException e) {
LOGGER.error("Request failed " + this.originalRequest.getURI(), e);
HttpRequestCache.this.registry.counter(baseMetricName + ".error").inc();
throw e;
} finally {
originalResponse.close();
if (originalResponse != null) {
originalResponse.close();
}
timerDownload.stop();
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ protected Response executeInternal(@Nonnull final HttpHeaders headers) throws IO
}
}
HttpResponse response = this.client.execute(this.request, this.context);
LOGGER.debug("Response: " + response.getStatusLine().getStatusCode() + " -- " + this.getURI());

return new Response(response);
}
}
Expand Down

0 comments on commit 35fb61b

Please sign in to comment.