@Override public synchronized void close() throws IOException { if (httpClient != null && httpClientCreated) { HttpClientUtils.closeQuietly(httpClient); } isClosed = true; }
@Override public void completed(HttpResponse response) { if (response.getStatusLine().getStatusCode() == HttpServletResponse.SC_OK) { serverIp2unhealthCount.put(serverIp, 0); if (serverListUnhealth.contains(serverIp)) { serverListUnhealth.remove(serverIp); } HttpClientUtils.closeQuietly(response); } }
HttpClientUtils.closeQuietly(response);
HttpClientUtils.closeQuietly(client); HttpClientUtils.closeQuietly(response);
protected void closeExternalClient() { if ( externalClient == null ) { return; } HttpClientUtils.closeQuietly(externalClient); externalClient = null; }
public static void closeConnections() { if (hc != null) { HttpClientUtils.closeQuietly(hc); hc = null; } }
@Override public void close() throws IOException { HttpClientUtils.closeQuietly(delegate); } }
@Override public synchronized void shutDown() { if (executor != null) { executor.shutdown(); executor = null; } if (dependentClient != null) { HttpClientUtils.closeQuietly(dependentClient); dependentClient = null; } }
@Override public void completed(HttpResponse response) { if (response.getStatusLine().getStatusCode() == HttpServletResponse.SC_OK) { serverIp2unhealthCount.put(serverIp, 0); if (serverListUnhealth.contains(serverIp)) { serverListUnhealth.remove(serverIp); } HttpClientUtils.closeQuietly(response); } }
public void close() { HttpClientUtils.closeQuietly(httpClient); httpClient = null; if (exFuncs != null) { for (XProcExtensionFunctionDefinition xf : exFuncs) { xf.close(); } } exFuncs = null; }
public void close() { HttpClientUtils.closeQuietly(httpClient); httpClient = null; if (exFuncs != null) { for (XProcExtensionFunctionDefinition xf : exFuncs) { xf.close(); } } exFuncs = null; }
@Override public <T> T execute(HttpUriRequest request, HttpClientContext context, CredentialsProvider provider, RequestFunction<T> func) throws IOException, UnauthorizedAccessException { HttpClient client = HttpClientBuilder.create().setDefaultCredentialsProvider(provider).build(); try { return func.run(client.execute(request, context)); } finally { HttpClientUtils.closeQuietly(client); } } }
/** * Interface method implementation. Posts to Flux Runtime API to redrive a task. */ @Override public void redriveTask(String stateMachineId, Long taskId) { CloseableHttpResponse httpResponse = null; httpResponse = postOverHttp(null, "/redrivetask/" + stateMachineId + "/taskId/"+ taskId); HttpClientUtils.closeQuietly(httpResponse); }
public static void checkAccessAllowed(HttpClient httpConn, String url) throws IOException { HttpGet getMethod = new HttpGet(url); HttpResponse response = httpConn.execute(getMethod); try { int statusCode = response.getStatusLine().getStatusCode(); assertTrue("Expected code == OK but got " + statusCode + " for request=" + url, statusCode == HttpURLConnection.HTTP_OK); String body = EntityUtils.toString(response.getEntity()); assertTrue("Get of " + url + " redirected to login page", !body.contains("j_security_check")); } finally { HttpClientUtils.closeQuietly(response); } }
public static void executeLogout(HttpClient httpConn, URL warURL) throws IOException { HttpGet logout = new HttpGet(warURL + "Logout"); HttpResponse response = httpConn.execute(logout); try { int statusCode = response.getStatusLine().getStatusCode(); assertTrue("Logout: Didn't see code 302 (HTTP_MOVED_TEMP), but saw instead " + statusCode, statusCode == HttpURLConnection.HTTP_MOVED_TEMP); Header location = response.getFirstHeader("Location"); assertTrue("Get of " + warURL + "Logout not redirected to login page", location.getValue().contains("index.html")); } finally { HttpClientUtils.closeQuietly(response); } }
public static void checkAccessDenied(HttpClient httpConn, String url) throws IOException { HttpGet getMethod = new HttpGet(url); HttpResponse response = httpConn.execute(getMethod); try { int statusCode = response.getStatusLine().getStatusCode(); assertTrue("Expected code == OK but got " + statusCode + " for request=" + url, statusCode == HttpURLConnection.HTTP_OK); String body = EntityUtils.toString(response.getEntity()); assertTrue("Redirected to login page for request=" + url + ", body[" + body + "]", body.indexOf("j_security_check") > 0); } finally { HttpClientUtils.closeQuietly(response); } }
public static void shutdown(Thing thing){ //先从缓存中取 HttpClientEntry entry = clients.get(thing.getMetadata().getPath()); if(entry != null){ HttpClientUtils.closeQuietly(entry.httpClient); } } }
@Override public void cancelEvent(String eventName, String correlationId) { CloseableHttpResponse httpResponse = null; try { final EventData eventData = new EventData(eventName, null, null, null, true); httpResponse = postOverHttp(eventData, "/" + correlationId + "/context/events?searchField=correlationId"); } catch (Exception e) { throw new RuntimeException(e); } finally { HttpClientUtils.closeQuietly(httpResponse); } }
public void execConfiguredQuery(String url, String destination) { HttpResponse response = null; boolean ret = true; response = exec(url); streamResponseToFile(response, destination); HttpClientUtils.closeQuietly(response); }
/** * Interface method implementation. Updates the status in persistence store by invoking suitable Flux runtime API * @see com.flipkart.flux.client.runtime.FluxRuntimeConnector#updateExecutionStatus(ExecutionUpdateData) */ public void updateExecutionStatus(ExecutionUpdateData executionUpdateData) { CloseableHttpResponse httpResponse = null; httpResponse = postOverHttp(executionUpdateData, "/" + executionUpdateData.getStateMachineId() + "/" + executionUpdateData.getTaskId() + "/status"); HttpClientUtils.closeQuietly(httpResponse); }