[ https://issues.apache.org/jira/browse/HTTPCLIENT-2379?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17995790#comment-17995790 ]
Arturo Bernal commented on HTTPCLIENT-2379: ------------------------------------------- [~olegk] I’ve trimmed the fix to two minimal checks: PerRoutePool.release decrement first; evict only when the counter reaches 0; throw if the entry was never tracked {code:java} final AtomicLong counter = entryMap.get(entry); if (counter == null) { // caller defect throw new IllegalStateException("Untracked PoolEntry released"); } long remaining = counter.decrementAndGet(); if (remaining == 0) { entryMap.remove(entry); // delegate once, on last release } return remaining; {code} and H2SharingConnPool.release ignore only the duplicate call that comes after the counter hit 0 {code:java} if (perRoutePool != null && perRoutePool.getCount(entry) == 0) { return; // duplicate release – no-op } {code} First (real) release delegates exactly once. Subsequent releases of the same entry are ignored, so the parent pool is not hit again. If an entry is released that was never tracked, we still fail fast. Does this look acceptable? > Multiple removal of same PoolEntry causes IllegalStateException in > H2SharingConnPool > ------------------------------------------------------------------------------------ > > Key: HTTPCLIENT-2379 > URL: https://issues.apache.org/jira/browse/HTTPCLIENT-2379 > Project: HttpComponents HttpClient > Issue Type: Bug > Components: HttpClient (async) > Affects Versions: 5.5 > Reporter: yhzdys > Priority: Major > Fix For: 5.5.1, 5.6-alpha1 > > Time Spent: 2h 40m > Remaining Estimate: 0h > > After enabling messageMultiplexing, the H2SharingConnPool is used to reuse > PoolEntry. > When making more than one request using the same connection, if the > connection is closed, > the pool.release(entry, reusable) method at H2SharingConnPool.java:183 will > throw the following exception: > ~~~java > throw new IllegalStateException("Pool entry is not present in the set of > leased entries"); > ~~~ > This occurs because the same connection is being removed multiple times. > https://github.com/yhzdys/httpcomponents-client/commit/c8256b33c3adb45cfa2a49efb2dacfb611da9ac1 -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@hc.apache.org For additional commands, e-mail: dev-h...@hc.apache.org