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:
This code might be able to be simplified:
~~~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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]