use of org.apache.hc.core5.util.DeadlineTimeoutException in project httpcomponents-core by apache.
the class TestStrictConnPool method testLeaseRequestLockTimeout.
@Test
public void testLeaseRequestLockTimeout() throws Exception {
final StrictConnPool<String, HttpConnection> pool = new StrictConnPool<>(1, 1);
final CountDownLatch lockHeld = new CountDownLatch(1);
final Thread holdInternalLock = new HoldInternalLockThread(pool, lockHeld);
// Start a thread to grab the internal conn pool lock
holdInternalLock.start();
// Wait until we know the internal lock is held
lockHeld.await();
// Attempt to get a connection while lock is held
final Future<PoolEntry<String, HttpConnection>> future2 = pool.lease("somehost", null, Timeout.ofMilliseconds(10), null);
final ExecutionException executionException = Assertions.assertThrows(ExecutionException.class, () -> future2.get());
Assertions.assertTrue(executionException.getCause() instanceof DeadlineTimeoutException);
// Cleanup
holdInternalLock.interrupt();
}
Aggregations