Source:
<code>public HttpConnection execute() throws IOException { boolean retry = true; int n = numberOfRetries; while (retry && n-- > 0) { connection = connectionFactory.openConnection(url); connection.setRequestProperty("User-Agent", USER_AGENT); if (url.getUserInfo() != null) { requestInterceptors.add(0, new BasicAuthInterceptor(url.getUserInfo())); } connection.setDoInput(true); connection.setRequestMethod(requestMethod); if (contentType != null) { connection.setRequestProperty("Content-type", contentType); } HttpConnectionInterceptorContext currentContext = new HttpConnectionInterceptorContext(this); for (HttpConnectionRequestInterceptor requestInterceptor : requestInterceptors) { currentContext = requestInterceptor.interceptRequest(currentContext); } for (Map.Entry<String, String> property : requestProperties.entrySet()) { connection.setRequestProperty(property.getKey(), property.getValue()); } if (input != null) { connection.setDoOutput(true); if (inputLength != -1) { connection.setFixedLengthStreamingMode((int) this.inputLength); } else { connection.setChunkedStreamingMode(1024); } InputStream is = input.getInputStream(); OutputStream os = connection.getOutputStream(); try { try { IOUtils.copy(is, os); os.flush(); <START> } finally { <END> is.close(); } } finally { os.close(); } } for (HttpConnectionResponseInterceptor responseInterceptor : responseInterceptors) { currentContext = responseInterceptor.interceptResponse(currentContext); } retry = currentContext.replayRequest; if (n == 0) { logger.info("Maximum number of retries reached"); } } return this; }</code><technical_language>I avoid nested try blocks IOUtils.closeQuietly()</technical_language>

Target:
public HttpConnection execute() throws IOException { boolean retry = true; int n = numberOfRetries; while (retry && n-- > 0) { connection = connectionFactory.openConnection(url); connection.setRequestProperty("User-Agent", USER_AGENT); if (url.getUserInfo() != null) { requestInterceptors.add(0, new BasicAuthInterceptor(url.getUserInfo())); } connection.setDoInput(true); connection.setRequestMethod(requestMethod); if (contentType != null) { connection.setRequestProperty("Content-type", contentType); } HttpConnectionInterceptorContext currentContext = new HttpConnectionInterceptorContext(this); for (HttpConnectionRequestInterceptor requestInterceptor : requestInterceptors) { currentContext = requestInterceptor.interceptRequest(currentContext); } for (Map.Entry<String, String> property : requestProperties.entrySet()) { connection.setRequestProperty(property.getKey(), property.getValue()); } if (input != null) { connection.setDoOutput(true); if (inputLength != -1) { connection.setFixedLengthStreamingMode((int) this.inputLength); } else { connection.setChunkedStreamingMode(1024); } InputStream is = input.getInputStream(); OutputStream os = connection.getOutputStream(); try { IOUtils.copy(is, os); os.flush(); } finally { IOUtils.closeQuietly(is); IOUtils.closeQuietly(os); } } for (HttpConnectionResponseInterceptor responseInterceptor : responseInterceptors) { currentContext = responseInterceptor.interceptResponse(currentContext); } retry = currentContext.replayRequest; if (n == 0) { logger.info("Maximum number of retries reached"); } } return this; }