public void testStatsIssue2039() throws InterruptedException, ExecutionException, TimeoutException {
final Config config = new Config();
final String name = "testStatsIssue2039";
config.addExecutorConfig(new ExecutorConfig(name).setQueueCapacity(1).setPoolSize(1));
final HazelcastInstance instance = createHazelcastInstance(config);
final IExecutorService executorService = instance.getExecutorService(name);
executorService.execute(new SleepLatchRunnable());
assertTrue(SleepLatchRunnable.startLatch.await(30, TimeUnit.SECONDS));
final Future waitingInQueue = executorService.submit(new EmptyRunnable());
final Future rejected = executorService.submit(new EmptyRunnable());
try {
rejected.get(1, TimeUnit.MINUTES);
} catch (Exception e) {
boolean isRejected = e.getCause() instanceof RejectedExecutionException;
if (!isRejected) {
fail(e.toString());
}
} finally {
SleepLatchRunnable.sleepLatch.countDown();
}
waitingInQueue.get(1, TimeUnit.MINUTES);
final LocalExecutorStats stats = executorService.getLocalExecutorStats();
assertEquals(2, stats.getStartedTaskCount());
assertEquals(0, stats.getPendingTaskCount());
}