/** * Shuts down this HTTP client object, releasing any resources that might be held open. This is * an optional method, and callers are not expected to call it, but can if they want to * explicitly release any open resources. Once a client has been shutdown, it cannot be used to * make more requests. */ public void shutdown() { clientExecutionTimer.shutdown(); httpRequestTimer.shutdown(); IdleConnectionReaper.removeConnectionManager(httpClient.getHttpClientConnectionManager()); httpClient.getHttpClientConnectionManager().shutdown(); }
/** * Shuts down this HTTP client object, releasing any resources that might be held open. This is * an optional method, and callers are not expected to call it, but can if they want to * explicitly release any open resources. Once a client has been shutdown, it cannot be used to * make more requests. */ public void shutdown() { clientExecutionTimer.shutdown(); httpRequestTimer.shutdown(); IdleConnectionReaper.removeConnectionManager(httpClient.getHttpClientConnectionManager()); httpClient.getHttpClientConnectionManager().shutdown(); }
@Test public void autoShutdown() throws Exception { // final int threadCount = getThreadCount(); assertEquals(0, IdleConnectionReaper.size()); for (int i = 0; i < 3; i++) { ClientConnectionManager m = new TestClientConnectionManager(); ClientConnectionManager m2 = new TestClientConnectionManager(); assertTrue(IdleConnectionReaper .registerConnectionManager(m)); assertEquals(1, IdleConnectionReaper.size()); // Thread.sleep(100); // assertTrue(getThreadCount() > threadCount); assertTrue(IdleConnectionReaper .registerConnectionManager(m2)); assertEquals(2, IdleConnectionReaper.size()); assertTrue(IdleConnectionReaper.removeConnectionManager(m)); assertEquals(1, IdleConnectionReaper.size()); // Thread.sleep(100); // assertTrue(getThreadCount() > threadCount); assertTrue(IdleConnectionReaper.removeConnectionManager(m2)); assertEquals(0, IdleConnectionReaper.size()); // Thread.sleep(100); // assertEquals(threadCount, getThreadCount()); assertFalse(IdleConnectionReaper.shutdown()); } // assertEquals(threadCount, getThreadCount()); }
/** * Shuts down this HTTP client object, releasing any resources that might be held open. This is * an optional method, and callers are not expected to call it, but can if they want to * explicitly release any open resources. Once a client has been shutdown, it cannot be used to * make more requests. */ public void shutdown() { clientExecutionTimer.shutdown(); httpRequestTimer.shutdown(); IdleConnectionReaper.removeConnectionManager(httpClient.getHttpClientConnectionManager()); httpClient.getHttpClientConnectionManager().shutdown(); }