Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Not A Problem
-
4.3
-
None
-
None
Description
Currently we've got code like this:
final HttpResponse response = client.execute(postReq); try { final StatusLine responseStatus = response.getStatusLine(); final String responseBody; if (response.getEntity() != null) responseBody = IOUtils.toString(response.getEntity().getContent()); else responseBody = null; if (responseStatus.getStatusCode() >= 200 && responseStatus.getStatusCode() < 300) { log.info("Job returned {}: {}", responseStatus, responseBody); } else log.error("Job returned {}: {}", responseStatus, responseBody); } finally { HttpClientUtils.closeQuietly(response); }
It would be great if this could be simplified to : (in Java 7)
try (final HttpResponse response = client.execute(postReq)) { ... }
Attachments
Issue Links
- relates to
-
HTTPCLIENT-910 AutoCloseInputStream.read() throws IOException after autoclose
- Closed
-
HTTPCLIENT-240 [HttpClient][patch]A more flexible SSLProtocolSocketFactory WRT SSLSocketFactory.
- Closed