yhzdys commented on code in PR #663: URL: https://github.com/apache/httpcomponents-client/pull/663#discussion_r2187972350
########## httpclient5/src/main/java/org/apache/hc/client5/http/impl/nio/H2SharingConnPool.java: ########## @@ -270,16 +270,18 @@ long track(final PoolEntry<T, C> entry) { PoolEntry<T, C> lease() { lock.lock(); try { - final PoolEntry<T, C> entry = entryMap.entrySet().stream() + return entryMap.entrySet().stream() + .filter(e -> { + final C conn = e.getKey().getConnection(); + return conn != null && conn.isOpen(); + }) .min(Comparator.comparingLong(e -> e.getValue().get())) .map(Map.Entry::getKey) + .map(e -> { Review Comment: @arturobernalg Perhaps this is better? ~~~java return entryMap.entrySet().stream() .filter(e -> { final C conn = e.getKey().getConnection(); return conn != null && conn.isOpen(); }) .min(Comparator.comparingLong(e -> e.getValue().get())) .map(e -> { e.getValue().incrementAndGet(); return e.getKey(); }) .orElse(null); ~~~ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org For additional commands, e-mail: dev-h...@hc.apache.org