Return-Path: X-Original-To: apmail-hc-dev-archive@www.apache.org Delivered-To: apmail-hc-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 43140109CB for ; Fri, 13 Sep 2013 16:12:19 +0000 (UTC) Received: (qmail 86086 invoked by uid 500); 13 Sep 2013 16:06:52 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 86052 invoked by uid 500); 13 Sep 2013 16:06:52 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 86021 invoked by uid 99); 13 Sep 2013 16:06:51 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 Sep 2013 16:06:51 +0000 Date: Fri, 13 Sep 2013 16:06:51 +0000 (UTC) From: "Hendy Irawan (JIRA)" To: dev@hc.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Resolved] (HTTPCORE-349) HttpResponse should implement Closeable (Java7 try-with-resources support) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HTTPCORE-349?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Hendy Irawan resolved HTTPCORE-349. ----------------------------------- Resolution: Not A Problem > 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 > Fix For: Future > > > 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 is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org