Source:
public <T> T send(final String method, final String url, final Map<String, String> headerFields, OutputStreamHandler outputStreamHandler, ResponseHandler<T> responseHandler) { HttpURLConnection connection = null; InputStream inputStream = null; String urlWithoutAuthInfo = removeUserInfo(url); try { URL parsedUrl = new URL(url); connection = (HttpURLConnection) parsedUrl.openConnection(); if (parsedUrl.getUserInfo() != null) { String basicAuth = "Basic " + DatatypeConverter.printBase64Binary(parsedUrl.getUserInfo().getBytes()); connection.setRequestProperty("Authorization", basicAuth); } connection.setDoOutput(true); connection.setRequestMethod(method); connection.setConnectTimeout((int) TimeUnit.SECONDS.toMillis(CONNECT_TIMEOUT_SEC)); connection.setReadTimeout((int) TimeUnit.SECONDS.toMillis(READ_TIMEOUT_SEC)); if (headerFields != null) { for (Map.Entry<String, String> header : headerFields.entrySet()) { connection.setRequestProperty(header.getKey(), header.getValue()); } } if (outputStreamHandler != null) { outputStreamHandler.withHttpURLConnection(connection.getOutputStream()); } inputStream = connection.getInputStream(); return responseHandler.handleResponse(inputStream, connection.getResponseCode(), null); } catch (IOException e) { if (connection != null) { inputStream = connection.getErrorStream(); try { return responseHandler.handleResponse(inputStream, getResponseCodeIfPossible(connection), e); } catch (IOException e1) { logger.warn("Error sending request to url {}: {}", method, urlWithoutAuthInfo, e.getMessage(), e); logger.warn("Error handling error response for request to url {}: {}", method, urlWithoutAuthInfo, e1.getMessage(), e1); try { logger.trace(new String(IOUtils.readToBytes(inputStream), "UTF-8")); } catch (IOException e2) { logger.trace("Could not read error stream: {}", e2.getMessage(), e2); } } } else { logger.warn("Error sending request to url {}: {}", method, urlWithoutAuthInfo, e.getMessage(), e); } return null; } finally { IOUtils.closeQuietly(inputStream); } }

Target:
public <T> T send(final String method, final String url, final Map<String, String> headerFields, OutputStreamHandler outputStreamHandler, ResponseHandler<T> responseHandler) { HttpURLConnection connection = null; InputStream inputStream = null; try { URL parsedUrl = new URL(url); connection = (HttpURLConnection) parsedUrl.openConnection(); if (parsedUrl.getUserInfo() != null) { String basicAuth = "Basic " + DatatypeConverter.printBase64Binary(parsedUrl.getUserInfo().getBytes()); connection.setRequestProperty("Authorization", basicAuth); } connection.setDoOutput(true); connection.setRequestMethod(method); connection.setConnectTimeout((int) TimeUnit.SECONDS.toMillis(CONNECT_TIMEOUT_SEC)); connection.setReadTimeout((int) TimeUnit.SECONDS.toMillis(READ_TIMEOUT_SEC)); if (headerFields != null) { for (Map.Entry<String, String> header : headerFields.entrySet()) { connection.setRequestProperty(header.getKey(), header.getValue()); } } if (outputStreamHandler != null) { outputStreamHandler.withHttpURLConnection(connection.getOutputStream()); } inputStream = connection.getInputStream(); return responseHandler.handleResponse(inputStream, connection.getResponseCode(), null); } catch (IOException e) { if (connection != null) { inputStream = connection.getErrorStream(); try { return responseHandler.handleResponse(inputStream, getResponseCodeIfPossible(connection), e); } catch (IOException e1) { logger.warn("Error sending request to url {}: {}", method, removeUserInfo(url), e.getMessage(), e); logger.warn("Error handling error response for request to url {}: {}", method, removeUserInfo(url), e1.getMessage(), e1); try { logger.trace(new String(IOUtils.readToBytes(inputStream), "UTF-8")); } catch (IOException e2) { logger.trace("Could not read error stream: {}", e2.getMessage(), e2); } } } else { logger.warn("Error sending request to url {}: {}", method, removeUserInfo(url), e.getMessage(), e); } return null; } finally { IOUtils.closeQuietly(inputStream); } }