You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2018/10/16 11:13:42 UTC

[cxf] branch master updated: CXF-7869 - Infinite loop in rest client

This is an automated email from the ASF dual-hosted git repository.

coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git


The following commit(s) were added to refs/heads/master by this push:
     new 3fec78a  CXF-7869 - Infinite loop in rest client
3fec78a is described below

commit 3fec78a935410d894add5490cd36d15603828509
Author: Colm O hEigeartaigh <co...@apache.org>
AuthorDate: Tue Oct 16 12:05:04 2018 +0100

    CXF-7869 - Infinite loop in rest client
---
 .../java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java
index 61c465a..85cb49f 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java
@@ -74,7 +74,8 @@ public class ClientImpl implements Client {
     private TLSConfiguration secConfig;
     private boolean closed;
     private Set<WebClient> baseClients =
-        Collections.newSetFromMap(new WeakHashMap<WebClient, Boolean>());
+        Collections.synchronizedSet(Collections.newSetFromMap(new WeakHashMap<WebClient, Boolean>()));
+
     public ClientImpl(Configuration config,
                       TLSConfiguration secConfig) {
         configImpl = new ClientConfigurableImpl<Client>(this, config);
@@ -84,8 +85,10 @@ public class ClientImpl implements Client {
     @Override
     public void close() {
         if (!closed) {
-            for (WebClient wc : baseClients) {
-                wc.close();
+            synchronized (baseClients) {
+                for (WebClient wc : baseClients) {
+                    wc.close();
+                }
             }
             baseClients = null;
             closed = true;
@@ -276,7 +279,7 @@ public class ClientImpl implements Client {
                         providers.add(p);
                     } else {
                         final Class<?> providerCls = ClassHelper.getRealClass(pf.getBus(), p);
-                        providers.add(new FilterProviderInfo<Object>(p.getClass(), 
+                        providers.add(new FilterProviderInfo<Object>(p.getClass(),
                             providerCls, p, pf.getBus(), contracts));
                     }
                 }
@@ -553,8 +556,8 @@ public class ClientImpl implements Client {
         }
     }
     private static Long getLongValue(Object o) {
-        return o instanceof Long ? (Long)o 
-            : o instanceof String ? Long.valueOf(o.toString()) 
+        return o instanceof Long ? (Long)o
+            : o instanceof String ? Long.valueOf(o.toString())
             : o instanceof Integer ? ((Integer)o).longValue() : null;
     }
     private static Integer getIntValue(Object o) {