jira-importer opened a new issue, #1519:
URL: https://github.com/apache/httpcomponents-core/issues/1519

   **[Hendy 
Irawan](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=ceefour)** 
opened 
**[HTTPCORE-349](https://issues.apache.org/jira/browse/HTTPCORE-349?redirect=false)**
 and commented
   
   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)) { 
       ...
   }
   ```
   
   
   
   ---
   
   **Affects:** 4.3
   
   **Issue Links:**
   - [HTTPCLIENT-910](https://issues.apache.org/jira/browse/HTTPCLIENT-910) 
AutoCloseInputStream.read() throws IOException after autoclose
   
   - [HTTPCLIENT-240](https://issues.apache.org/jira/browse/HTTPCLIENT-240) 
[HttpClient][patch]A more flexible SSLProtocolSocketFactory WRT 
SSLSocketFactory.
   
   
   1 votes, 2 watchers
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to