Source:
<code>private void startClientAndTestPool(Configuration conf) throws Exception { Injector injector = Guice.createInjector( new ConfigModule(conf), new ZKModule(), new DiscoveryModules().getDistributedModules(), new TransactionModules().getDistributedModules(), new TransactionClientModule() ); ZKClientService zkClient = injector.getInstance(ZKClientService.class); zkClient.startAndWait(); final PooledClientProvider clientProvider = new PooledClientProvider(conf, injector.getInstance(DiscoveryServiceClient.class)); try (CloseableThriftClient closeableThriftClient = clientProvider.getCloseableClient()) { } List<Future<Integer>> clientIds = new ArrayList<Future<Integer>>(); ExecutorService executor = Executors.newFixedThreadPool(MAX_CLIENT_COUNT + 1); for (int i = 0; i < MAX_CLIENT_COUNT + 1; i++) { clientIds.add(executor.submit(new RetrieveClient(clientProvider, CLIENT_OBTAIN_TIMEOUT / 2))); } Set<Integer> ids = new HashSet<Integer>(); for (Future<Integer> id : clientIds) { ids.add(id.get()); } try { for (int i = 0; i < MAX_CLIENT_COUNT + 1; i++) { clientIds.add(executor.submit(new RetrieveClient(clientProvider, CLIENT_OBTAIN_TIMEOUT * 2))); } for (Future<Integer> clientId : clientIds) { clientId.get(); } Assert.fail(String.format("Expected one thread to not obtain a client within %s milliseconds.", CLIENT_OBTAIN_TIMEOUT)); } catch (ExecutionException expected) { Assert.assertEquals(TimeoutException.class, expected.getCause().getClass()); } executor.shutdown(); <START> Assert.assertEquals(MAX_CLIENT_COUNT, ids.size()); <END> }</code><technical_language>This assertion moved part of test</technical_language>

Target:
private void startClientAndTestPool(Configuration conf) throws Exception { Injector injector = Guice.createInjector( new ConfigModule(conf), new ZKModule(), new DiscoveryModules().getDistributedModules(), new TransactionModules().getDistributedModules(), new TransactionClientModule() ); ZKClientService zkClient = injector.getInstance(ZKClientService.class); zkClient.startAndWait(); final PooledClientProvider clientProvider = new PooledClientProvider(conf, injector.getInstance(DiscoveryServiceClient.class)); try (CloseableThriftClient closeableThriftClient = clientProvider.getCloseableClient()) { } List<Future<Integer>> clientIds = new ArrayList<Future<Integer>>(); ExecutorService executor = Executors.newFixedThreadPool(MAX_CLIENT_COUNT + 1); for (int i = 0; i < MAX_CLIENT_COUNT + 1; i++) { clientIds.add(executor.submit(new RetrieveClient(clientProvider, CLIENT_OBTAIN_TIMEOUT / 2))); } Set<Integer> ids = new HashSet<Integer>(); for (Future<Integer> id : clientIds) { ids.add(id.get()); } Assert.assertEquals(MAX_CLIENT_COUNT, ids.size()); for (int i = 0; i < MAX_CLIENT_COUNT + 1; i++) { clientIds.add(executor.submit(new RetrieveClient(clientProvider, CLIENT_OBTAIN_TIMEOUT * 2))); } int numTimeoutExceptions = 0; for (Future<Integer> clientId : clientIds) { try { clientId.get(); } catch (ExecutionException expected) { Assert.assertEquals(TimeoutException.class, expected.getCause().getClass()); numTimeoutExceptions++; } } Assert.assertEquals(String.format("Expected one thread to not obtain a client within %s milliseconds.", CLIENT_OBTAIN_TIMEOUT), 1, numTimeoutExceptions); executor.shutdown(); }