ffang commented on code in PR #2571:
URL: https://github.com/apache/cxf/pull/2571#discussion_r2333534821


##########
rt/transports/http/src/main/java/org/apache/cxf/transport/http/HttpClientHTTPConduit.java:
##########
@@ -229,23 +207,29 @@ RefCount<HttpClient> computeIfAbsent(final boolean 
shareHttpClient, final HTTPCl
 
             // Do not share if it is not allowed for the conduit or cache 
capacity is exceeded
             if (!shareHttpClient || clients.size() >= MAX_SIZE) {
-                return new RefCount<HttpClient>(supplier.get(), policy, 
clientParameters, () -> { }).acquire();
+                return new RefCount<HttpClient>(supplier.get(), policy, 
clientParameters, () -> { });
             }
 
             lock.lock();
             try {
-                for (final RefCount<HttpClient> p: clients) {
-                    if (cpc.equals(p.policy(), policy) && 
p.clientParameters().equals(clientParameters)) {
-                        return p.acquire();
+                try {
+                    for (final RefCount<HttpClient> p: clients) {
+                        if (p.isClosed() /* skip the closed but not yet 
removed clients */) {
+                            continue;
+                        } else if (cpc.equals(p.policy(), policy) && 
p.clientParameters().equals(clientParameters)) {
+                            return p.acquire();
+                        }
                     }
+                } catch (final IllegalStateException ex) {
+                    /* The client is being shutdown */
                 }
 

Review Comment:
   Hi @reta ,
   
   Sorry, just realized that my previous comments were marked as pending so you 
can't actually see it.
   
   Please take a look and let me know if my change is OK for you.
   
   Thanks!
   Freeman



-- 
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]

Reply via email to