/** * Closes any http connections kept open by this http response. */ protected void closeConnection(HttpResponse response) { if (response != null) client.close(response); }
/** * Returns the runtime information as a JSON string. * * @return the runtime information * @throws IOException * if reading the response body fails */ private String getRuntimeInfo(String hostUrl) throws IOException { HttpGet get = new HttpGet(UrlSupport.concat(hostUrl, "/info/components.json")); HttpResponse response = null; try { response = httpClient.execute(get); if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) return null; return EntityUtils.toString(response.getEntity()); } finally { httpClient.close(response); } }
@Override public Either<Exception, A> run(Function<HttpResponse, A> f) { HttpResponse response = null; try { response = client.execute(req); return right(f.apply(response)); } catch (Exception e) { return left(e); } finally { if (response != null) { client.close(response); } } } };
@Override public Either<Exception, A> apply(Function<HttpResponse, A> responseHandler) { HttpResponse response = null; try { response = client.execute(httpUriRequest); return right(responseHandler.apply(response)); } catch (Exception e) { return left(e); } finally { if (response != null) { client.close(response); } } } };
client.close(response);
logger.warn("Unable to dispatch job {}", job.getId(), e); } finally { client.close(response); setCurrentJob(null);