minor fix

This commit is contained in:
DOHA 2016-12-14 00:50:35 +02:00
parent 12afdf20a1
commit ca4d69bf75
1 changed files with 6 additions and 5 deletions

View File

@ -218,7 +218,7 @@ public class HttpClientConnectionManagementLiveTest {
final HeaderElement he = it.nextElement(); final HeaderElement he = it.nextElement();
final String param = he.getName(); final String param = he.getName();
final String value = he.getValue(); final String value = he.getValue();
if (value != null && param.equalsIgnoreCase("timeout")) { if ((value != null) && param.equalsIgnoreCase("timeout")) {
return Long.parseLong(value) * 1000; return Long.parseLong(value) * 1000;
} }
} }
@ -251,9 +251,9 @@ public class HttpClientConnectionManagementLiveTest {
basicConnManager.connect(conn, route, 1000, context); basicConnManager.connect(conn, route, 1000, context);
basicConnManager.routeComplete(conn, route, context); basicConnManager.routeComplete(conn, route, context);
final HttpRequestExecutor exeRequest = new HttpRequestExecutor(); final HttpRequestExecutor exeRequest = new HttpRequestExecutor();
context.setTargetHost((new HttpHost("www.baeldung.com", 80))); context.setTargetHost((new HttpHost("http://httpbin.org", 80)));
final HttpGet get = new HttpGet("http://www.baeldung.com"); final HttpGet get = new HttpGet("http://httpbin.org");
exeRequest.execute(get, conn, context); exeRequest.execute(get, conn, context);
conn.isResponseAvailable(1000); conn.isResponseAvailable(1000);
basicConnManager.releaseConnection(conn, null, 1, TimeUnit.SECONDS); basicConnManager.releaseConnection(conn, null, 1, TimeUnit.SECONDS);
@ -282,8 +282,9 @@ public class HttpClientConnectionManagementLiveTest {
for (final MultiHttpClientConnThread thread : threads) { for (final MultiHttpClientConnThread thread : threads) {
thread.join(10000); thread.join(10000);
countConnMade++; countConnMade++;
if (countConnMade == 0) if (countConnMade == 0) {
assertTrue(thread.getLeasedConn() == 5); assertTrue(thread.getLeasedConn() == 5);
}
} }
} }
@ -356,7 +357,7 @@ public class HttpClientConnectionManagementLiveTest {
// @Ignore // @Ignore
// 8.2 ARTICLE VERSION // 8.2 ARTICLE VERSION
public final void whenCustomizedIdleConnMonitor_thenNoExceptions() throws InterruptedException, IOException { public final void whenCustomizedIdleConnMonitor_thenNoExceptions() throws InterruptedException, IOException {
final HttpGet get = new HttpGet("http://google.com"); new HttpGet("http://google.com");
poolingConnManager = new PoolingHttpClientConnectionManager(); poolingConnManager = new PoolingHttpClientConnectionManager();
client = HttpClients.custom().setConnectionManager(poolingConnManager).build(); client = HttpClients.custom().setConnectionManager(poolingConnManager).build();
final IdleConnectionMonitorThread staleMonitor = new IdleConnectionMonitorThread(poolingConnManager); final IdleConnectionMonitorThread staleMonitor = new IdleConnectionMonitorThread(poolingConnManager);