@Override public synchronized void handleConnection(FakeConnection conn) { assertSame(conn.context, mgr.context); Pool<FakeConnection> pool = mgr.pool(); handleLock.set(Thread.holdsLock(pool)); super.handleConnection(conn); } };
@Override public synchronized void handleFailure(Throwable failure) { assertNull(Vertx.currentContext()); Pool<FakeConnection> pool = mgr.pool(); holdsLock.set(Thread.holdsLock(pool)); super.handleFailure(failure); } };
@Test public void testSynchronousConnectionFailure() { Throwable cause = new Throwable(); ConnectionProvider<FakeConnection> connector = new FakeConnectionProviderBase() { @Override public void connect(ConnectionListener<FakeConnection> listener, ContextInternal context, Handler<AsyncResult<ConnectResult<FakeConnection>>> handler) { handler.handle(Future.failedFuture(cause)); } }; FakeConnectionManager mgr = new FakeConnectionManager(3, 3, connector); for (int i = 0;i < 4;i++) { FakeWaiter waiter = new FakeWaiter(); mgr.getConnection(waiter); waitUntil(waiter::isFailure); waiter.assertFailure(cause); assertEquals(0, mgr.pool().weight()); } assertTrue(mgr.closed()); }
@Test public void testSynchronousConnectionFailure() { Throwable cause = new Throwable(); ConnectionProvider<FakeConnection> connector = new FakeConnectionProviderBase() { @Override public void connect(ConnectionListener<FakeConnection> listener, ContextInternal context, Handler<AsyncResult<ConnectResult<FakeConnection>>> handler) { handler.handle(Future.failedFuture(cause)); } }; FakeConnectionManager mgr = new FakeConnectionManager(3, 3, connector); for (int i = 0;i < 4;i++) { FakeWaiter waiter = new FakeWaiter(); mgr.getConnection(waiter); waitUntil(waiter::isFailure); waiter.assertFailure(cause); assertEquals(0, mgr.pool().weight()); } assertTrue(mgr.closed()); }
@Override public synchronized void handleFailure(Throwable failure) { assertNull(Vertx.currentContext()); Pool<FakeConnection> pool = mgr.pool(); holdsLock.set(Thread.holdsLock(pool)); super.handleFailure(failure); } };
@Override public synchronized void handleConnection(FakeConnection conn) { assertSame(conn.context, mgr.context); Pool<FakeConnection> pool = mgr.pool(); handleLock.set(Thread.holdsLock(pool)); super.handleConnection(conn); } };