[ 
https://issues.apache.org/jira/browse/HTTPCORE-349?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Oleg Kalnichevski updated HTTPCORE-349:
---------------------------------------
    Fix Version/s:     (was: Future)

> HttpResponse should implement Closeable (Java7 try-with-resources support)
> --------------------------------------------------------------------------
>
>                 Key: HTTPCORE-349
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-349
>             Project: HttpComponents HttpCore
>          Issue Type: Improvement
>          Components: HttpCore
>    Affects Versions: 4.3
>            Reporter: Hendy Irawan
>            Priority: Major
>
> Currently we've got code like this:
> {code}
> 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);
> }
> {code}
> It would be great if this could be simplified to : (in Java 7)
> {code}
> try (final HttpResponse response = client.execute(postReq)) { 
>     ...
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to