Source:
private long createConnection(Waiter<C> waiter) { Holder<C> holder = new Holder<>(); ConnectionListener<C> listener = new ConnectionListener<C>() { @Override public void onConnectSuccess(C conn, long concurrency, Channel channel, ContextImpl context, long initialWeight, long actualWeight) { waiter.initConnection(context, conn); boolean usable; synchronized (Pool.this) { usable = initConnection(waiter, holder, context, concurrency, conn, channel, initialWeight, actualWeight); } if (usable) { boolean consumed = deliverToWaiter(holder, waiter); synchronized (Pool.this) { if (!consumed) { synchronized (this) { recycleConnection(holder, 1,false); } } checkPending(); } } else { synchronized (Pool.this) { checkPending(); } } } @Override public void onConnectFailure(ContextImpl context, Throwable err, long weight) { waiter.handleFailure(context, err); synchronized (Pool.this) { Pool.this.weight -= weight; all.remove(holder); checkPending(); checkClose(); } } @Override public void onConcurrencyChange(long concurrency) { synchronized (Pool.this) { if (holder.concurrency < concurrency) { long diff = concurrency - holder.concurrency; capacity += diff; if (holder.capacity == 0) { available.add(holder); } holder.capacity += diff; holder.concurrency = concurrency; checkPending(); } else if (holder.concurrency > concurrency) { throw new UnsupportedOperationException("Not yet implemented"); } } } @Override public void onRecycle(int capacity, boolean disposable) { if (capacity < 0) { throw new IllegalArgumentException("Illegal capacity"); } Pool.this.recycle(holder, capacity, disposable); } @Override public void onClose() { Pool.this.closed(holder); } }; all.add(holder); return connector.connect(listener, metric, waiter.context, ssl, peerHost, host, port); }

Target:
private long createConnection(Waiter<C> waiter) { Holder<C> holder = new Holder<>(); ConnectionListener<C> listener = new ConnectionListener<C>() { @Override public void onConnectSuccess(C conn, long concurrency, Channel channel, ContextImpl context, long initialWeight, long actualWeight) { synchronized (Pool.this) { initConnection(holder, context, concurrency, conn, channel, initialWeight, actualWeight); } waiter.initConnection(context, conn); synchronized (Pool.this) { if (holder.capacity == 0) { waitersQueue.add(waiter); checkPending(); return; } waitersCount--; holder.capacity--; if (holder.capacity > 0) { available.add(holder); } } boolean consumed = deliverToWaiter(holder, waiter); synchronized (Pool.this) { if (!consumed) { recycleConnection(holder, 1,false); } checkPending(); } } @Override public void onConnectFailure(ContextImpl context, Throwable err, long weight) { waiter.handleFailure(context, err); synchronized (Pool.this) { waitersCount--; Pool.this.weight -= weight; holder.removed = true; checkPending(); checkClose(); } } @Override public void onConcurrencyChange(long concurrency) { synchronized (Pool.this) { if (holder.removed) { return; } if (holder.concurrency < concurrency) { long diff = concurrency - holder.concurrency; if (holder.capacity == 0) { available.add(holder); } holder.capacity += diff; holder.concurrency = concurrency; checkPending(); } else if (holder.concurrency > concurrency) { throw new UnsupportedOperationException("Not yet implemented"); } } } @Override public void onRecycle(int capacity, boolean disposable) { if (capacity < 0) { throw new IllegalArgumentException("Illegal capacity"); } synchronized (Pool.this) { if (holder.removed) { return; } recycle(holder, capacity, disposable); } } @Override public void onDiscard() { synchronized (Pool.this) { if (holder.removed) { return; } closed(holder); } } }; return connector.connect(listener, waiter.context); }