StrictConnPool implements ManagedConnPool<T, C> { @Override public void release(final PoolEntry<T, C> entry, final boolean reusable) { if (entry == null) { return; } if (this.isShutDown.get()) { return; } if (!reusable) { entry.discardConnection(CloseMode.GRACEFUL); } this.lock.lock(); try { if (this.leased.remove(entry)) { if (this.connPoolListener != null) { this.connPoolListener.onRelease(entry.getRoute(), this); } final PerRoutePool<T, C> pool = getPool(entry.getRoute()); final boolean keepAlive = entry.hasConnection() && reusable; pool.free(entry, keepAlive); if (keepAlive) { switch (policy) { case LIFO: this.available.addFirst(entry); break; case FIFO: this.available.addLast(entry); break; default: throw new IllegalStateException("Unexpected ConnPoolPolicy value: " + policy); } } else { entry.discardConnection(CloseMode.GRACEFUL); } processNextPendingRequest(); } else { throw new IllegalStateException("Pool entry is not present in the set of leased entries"); } } finally { this.lock.unlock(); } fireCallbacks(); } StrictConnPool(
            final int defaultMaxPerRoute,
            final int maxTotal,
            final TimeValue timeToLive,
            final PoolReusePolicy policy,
            final DisposalCallback<C> disposalCallback,
            final ConnPoolListener<T> connPoolListener);  StrictConnPool(
            final int defaultMaxPerRoute,
            final int maxTotal,
            final TimeValue timeToLive,
            final PoolReusePolicy policy,
            final ConnPoolListener<T> connPoolListener);  StrictConnPool(final int defaultMaxPerRoute, final int maxTotal); boolean isShutdown(); @Override void close(final CloseMode closeMode); @Override void close(); @Override Future<PoolEntry<T, C>> lease(
            final T route, final Object state,
            final Timeout requestTimeout,
            final FutureCallback<PoolEntry<T, C>> callback); Future<PoolEntry<T, C>> lease(final T route, final Object state); @Override void release(final PoolEntry<T, C> entry, final boolean reusable); void validatePendingRequests(); @Override void setMaxTotal(final int max); @Override int getMaxTotal(); @Override void setDefaultMaxPerRoute(final int max); @Override int getDefaultMaxPerRoute(); @Override void setMaxPerRoute(final T route, final int max); @Override int getMaxPerRoute(final T route); @Override PoolStats getTotalStats(); @Override PoolStats getStats(final T route); @Override Set<T> getRoutes(); void enumAvailable(final Callback<PoolEntry<T, C>> callback); void enumLeased(final Callback<PoolEntry<T, C>> callback); @Override void closeIdle(final TimeValue idleTime); @Override void closeExpired(); @Override String toString();  }
@Test(expected = IllegalStateException.class) public void testReleaseUnknownEntry() throws Exception { final StrictConnPool<String, HttpConnection> pool = new StrictConnPool<>(2, 2); pool.release(new PoolEntry<String, HttpConnection>("somehost"), true); }