You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2018/04/27 17:34:03 UTC

[cxf] branch 3.1.x-fixes updated (9e44c00 -> efe1df2)

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

dkulp pushed a change to branch 3.1.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git.


    from 9e44c00  Recording .gitmergeinfo Changes
     new e6472ac  [CXF-7591, CXF-7710] More updates to the response context handling
     new 1566ba6  Recording .gitmergeinfo Changes
     new 6c45abc  no need of instantiating so much objects when security manager is null, let's keep the runtime fast
     new 79bcc1b  [CXF-7671]should avoid reverse dns resolution in AsyncHTTPConduit for the proxy host address
     new efe1df2  Generate a help mojo for the cxf-codegen-plugin, so the user can get help regarding goals and parameters from the command line. You can read more about how to use a help mojo here: https://maven.apache.org/plugin-tools/maven-plugin-plugin/help-mojo.html

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .gitmergeinfo                                      |   1 +
 .../cxf/common/classloader/ClassLoaderUtils.java   |  34 +++-
 .../main/java/org/apache/cxf/endpoint/Client.java  |   3 +-
 .../java/org/apache/cxf/endpoint/ClientImpl.java   | 171 +++++++++++++--------
 maven-plugins/codegen-plugin/pom.xml               |   6 +
 .../http/asyncclient/AsyncHTTPConduit.java         |   2 +-
 6 files changed, 140 insertions(+), 77 deletions(-)

-- 
To stop receiving notification emails like this one, please contact
dkulp@apache.org.

[cxf] 03/05: no need of instantiating so much objects when security manager is null, let's keep the runtime fast

Posted by dk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dkulp pushed a commit to branch 3.1.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 6c45abc4d057811b01f5aaf88f0d5ef617a5b7e9
Author: Romain Manni-Bucau <rm...@gmail.com>
AuthorDate: Fri Apr 27 15:09:12 2018 +0200

    no need of instantiating so much objects when security manager is null, let's keep the runtime fast
---
 .../cxf/common/classloader/ClassLoaderUtils.java   | 34 +++++++++++++++++-----
 1 file changed, 27 insertions(+), 7 deletions(-)

diff --git a/core/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java b/core/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java
index 90b0626..7aa6aef 100644
--- a/core/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java
+++ b/core/src/main/java/org/apache/cxf/common/classloader/ClassLoaderUtils.java
@@ -36,26 +36,46 @@ import java.util.List;
  * verify any change on 6 different application servers.
  */
 public final class ClassLoaderUtils {
-    
+    private static final boolean SKIP_SM = System.getSecurityManager() == null;
+
     private ClassLoaderUtils() {
     }
     
     public static class ClassLoaderHolder {
         ClassLoader loader;
-        ClassLoaderHolder(ClassLoader c) {
-            loader = c;
+        Thread thread;
+
+        ClassLoaderHolder(final ClassLoader c, final Thread thread) {
+            this.loader = c;
+            this.thread = thread;
         }
         
         public void reset() {
-            ClassLoaderUtils.setThreadContextClassloader(loader);
+            if (SKIP_SM) {
+                thread.setContextClassLoader(loader);
+            } else {
+                AccessController.doPrivileged(new PrivilegedAction<Void>() {
+                    public Void run() {
+                        thread.setContextClassLoader(loader);
+                        return null;
+                    }
+                });
+            }
         }
     }
     public static ClassLoaderHolder setThreadContextClassloader(final ClassLoader newLoader) {
+        if (SKIP_SM) {
+            final Thread thread = Thread.currentThread();
+            final ClassLoader l = thread.getContextClassLoader();
+            thread.setContextClassLoader(newLoader);
+            return new ClassLoaderHolder(l, thread);
+        }
         return AccessController.doPrivileged(new PrivilegedAction<ClassLoaderHolder>() {
             public ClassLoaderHolder run() {
-                ClassLoader l = Thread.currentThread().getContextClassLoader();
-                Thread.currentThread().setContextClassLoader(newLoader);
-                return new ClassLoaderHolder(l);
+                final Thread thread = Thread.currentThread();
+                final ClassLoader l = thread.getContextClassLoader();
+                thread.setContextClassLoader(newLoader);
+                return new ClassLoaderHolder(l, thread);
             }
         });
     }

-- 
To stop receiving notification emails like this one, please contact
dkulp@apache.org.

[cxf] 04/05: [CXF-7671]should avoid reverse dns resolution in AsyncHTTPConduit for the proxy host address

Posted by dk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dkulp pushed a commit to branch 3.1.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 79bcc1bd5f4c695596cb1d2e2e3a4a5396427c8e
Author: Freeman Fang <fr...@gmail.com>
AuthorDate: Thu Mar 8 11:22:06 2018 +0800

    [CXF-7671]should avoid reverse dns resolution in AsyncHTTPConduit for the proxy host address
    
    (cherry picked from commit 61983861fe4cb26f5b9c4c6d4ca5e85c10cbd34b)
---
 .../org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java b/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
index 4b4b934..57af587 100755
--- a/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
+++ b/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
@@ -223,7 +223,7 @@ public class AsyncHTTPConduit extends URLConnectionHTTPConduit {
         Proxy p = proxyFactory.createProxy(csPolicy, uri);
         if (p != null && p.type() != Proxy.Type.DIRECT) {
             InetSocketAddress isa = (InetSocketAddress)p.address();
-            HttpHost proxy = new HttpHost(isa.getHostName(), isa.getPort());
+            HttpHost proxy = new HttpHost(isa.getHostString(), isa.getPort());
             b.setProxy(proxy);
         }
         e.setConfig(b.build());

-- 
To stop receiving notification emails like this one, please contact
dkulp@apache.org.

[cxf] 01/05: [CXF-7591, CXF-7710] More updates to the response context handling

Posted by dk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dkulp pushed a commit to branch 3.1.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit e6472ac1ba5d57c8ae841ef63ee9a810df734161
Author: Daniel Kulp <dk...@apache.org>
AuthorDate: Fri Apr 27 12:31:09 2018 -0400

    [CXF-7591, CXF-7710] More updates to the response context handling
    
    (cherry picked from commit 6abad1864187457984b0dff2622eafb4b5df5305)
---
 .../main/java/org/apache/cxf/endpoint/Client.java  |   3 +-
 .../java/org/apache/cxf/endpoint/ClientImpl.java   | 171 +++++++++++++--------
 2 files changed, 105 insertions(+), 69 deletions(-)

diff --git a/core/src/main/java/org/apache/cxf/endpoint/Client.java b/core/src/main/java/org/apache/cxf/endpoint/Client.java
index 8a2a06f..d266dfd 100644
--- a/core/src/main/java/org/apache/cxf/endpoint/Client.java
+++ b/core/src/main/java/org/apache/cxf/endpoint/Client.java
@@ -239,8 +239,7 @@ public interface Client extends InterceptorProvider, MessageObserver, ConduitSel
      * @return true if the request context is a thread local
      */
     boolean isThreadLocalRequestContext();
-
-
+    
     Endpoint getEndpoint();
 
     /**
diff --git a/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java b/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
index 8298cbc..6d2c8ce 100644
--- a/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
+++ b/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
@@ -96,11 +96,11 @@ public class ClientImpl
 
     protected Map<String, Object> currentRequestContext = new ConcurrentHashMap<String, Object>(8, 0.75f, 4);
     protected Thread latestContextThread;
-    protected Map<Thread, Map<String, Object>> requestContext
-        = Collections.synchronizedMap(new WeakHashMap<Thread, Map<String, Object>>());
+    protected Map<Thread, EchoContext> requestContext
+        = Collections.synchronizedMap(new WeakHashMap<Thread, EchoContext>());
 
-    protected Map<Thread, Map<String, Object>> responseContext 
-        = Collections.synchronizedMap(new WeakHashMap<Thread, Map<String, Object>>());
+    protected Map<Thread, ResponseContext> responseContext
+        = Collections.synchronizedMap(new WeakHashMap<Thread, ResponseContext>());
 
     protected Executor executor;
 
@@ -239,12 +239,17 @@ public class ClientImpl
         return getConduitSelector().getEndpoint();
     }
 
-
+    public void releaseThreadContexts() {
+        final Thread t = Thread.currentThread();
+        requestContext.remove(t);
+        responseContext.remove(t);
+    }
+    
     public Map<String, Object> getRequestContext() {
         if (isThreadLocalRequestContext()) {
             final Thread t = Thread.currentThread();
             if (!requestContext.containsKey(t)) {
-                Map<String, Object> freshRequestContext = new EchoContext(currentRequestContext);
+                EchoContext freshRequestContext = new EchoContext(currentRequestContext, requestContext);
                 requestContext.put(t, freshRequestContext);
             }
             latestContextThread = t;
@@ -253,28 +258,30 @@ public class ClientImpl
         return currentRequestContext;
     }
     public Map<String, Object> getResponseContext() {
-        if (!responseContext.containsKey(Thread.currentThread())) {
-            final Thread t = Thread.currentThread();
-            responseContext.put(t, new HashMap<String, Object>() {
-                private static final long serialVersionUID = 1L;
-                @Override
-                public void clear() {
-                    super.clear();
-                    try {
-                        for (Map.Entry<Thread, Map<String, Object>> ent : responseContext.entrySet()) {
-                            if (ent.getValue() == this) {
-                                responseContext.remove(ent.getKey());
-                                return;
-                            }
-                        }
-                    } catch (Throwable t) {
-                        //ignore
-                    }
-                }
-            });
+        final Thread t = Thread.currentThread();
+        ResponseContext ret = responseContext.get(t);
+        if (ret == null) {
+            ret = new ResponseContext();
+            responseContext.put(t, ret);
         }
-        return responseContext.get(Thread.currentThread());
-
+        return ret;
+    }
+    protected Map<String, Object> newResponseContext() {
+        final Thread t = Thread.currentThread();
+        ResponseContext ret = new ResponseContext();
+        responseContext.put(t, ret);
+        return ret;
+    }
+    protected Map<String, Object> reloadResponseContext(Map<String, Object> o) {
+        final Thread t = Thread.currentThread();
+        ResponseContext ctx = responseContext.get(t);
+        if (ctx == null) {
+            ctx = new ResponseContext(o);
+            responseContext.put(t, ctx);
+        } else if (o != ctx) {
+            ctx.reload(o);
+        }
+        return ctx;
     }
     public boolean isThreadLocalRequestContext() {
         Object o = currentRequestContext.get(THREAD_LOCAL_REQUEST_CONTEXT);
@@ -336,32 +343,13 @@ public class ClientImpl
     public Object[] invoke(BindingOperationInfo oi,
                            Object[] params,
                            Exchange exchange) throws Exception {
-        Map<String, Object> context = new HashMap<String, Object>();
-        Map<String, Object> resp = new HashMap<String, Object>();
-        Map<String, Object> req = new HashMap<String, Object>(getRequestContext());
-        context.put(RESPONSE_CONTEXT, resp);
-        context.put(REQUEST_CONTEXT, req);
-        try {
-            return invoke(oi, params, context, exchange);
-        } finally {
-            if (responseContext != null) {
-                responseContext.put(Thread.currentThread(), resp);
-            }
-        }
+        Map<String, Object> context = new HashMap<>();
+        return invoke(oi, params, context, exchange);
     }
     public Object[] invoke(BindingOperationInfo oi,
                            Object[] params,
                            Map<String, Object> context) throws Exception {
-        try {
-            return invoke(oi, params, context, (Exchange)null);
-        } finally {
-            if (context != null) {
-                Map<String, Object> resp = CastUtils.cast((Map<?, ?>)context.get(RESPONSE_CONTEXT));
-                if (resp != null && responseContext != null) {
-                    responseContext.put(Thread.currentThread(), resp);
-                }
-            }
-        }
+        return invoke(oi, params, context, (Exchange)null);
     }
 
     public void invoke(ClientCallback callback,
@@ -451,6 +439,7 @@ public class ClientImpl
                               Exchange exchange) throws Exception {
         Bus origBus = BusFactory.getAndSetThreadDefaultBus(bus);
         ClassLoaderHolder origLoader = null;
+        Map<String, Object> resContext = null;
         try {
             ClassLoader loader = bus.getExtension(ClassLoader.class);
             if (loader != null) {
@@ -469,7 +458,6 @@ public class ClientImpl
             // Make sure INVOCATION CONTEXT, REQUEST_CONTEXT and RESPONSE_CONTEXT are present
             // on message
             Map<String, Object> reqContext = null;
-            Map<String, Object> resContext = null;
             if (context == null) {
                 context = new HashMap<String, Object>();
             }
@@ -480,7 +468,7 @@ public class ClientImpl
                 context.put(REQUEST_CONTEXT, reqContext);
             }
             if (resContext == null) {
-                resContext = new HashMap<String, Object>();
+                resContext = newResponseContext();
                 context.put(RESPONSE_CONTEXT, resContext);
             }
             
@@ -516,7 +504,7 @@ public class ClientImpl
                                 // handle the right response
                                 List<Object> resList = null;
                                 Message inMsg = message.getExchange().getInMessage();
-                                Map<String, Object> ctx = responseContext.get(Thread.currentThread());
+                                Map<String, Object> ctx = getResponseContext();
                                 resList = CastUtils.cast(inMsg.getContent(List.class));
                                 Object[] result = resList == null ? null : resList.toArray();
                                 callback.handleResponse(ctx, result);
@@ -544,6 +532,9 @@ public class ClientImpl
                 return processResult(message, exchange, oi, resContext);
             }
         } finally {
+            if (callback == null) {
+                reloadResponseContext(resContext);
+            }
             if (origLoader != null) {
                 origLoader.reset();
             }
@@ -647,7 +638,7 @@ public class ClientImpl
                 resContext.putAll(inMsg);
                 // remove the recursive reference if present
                 resContext.remove(Message.INVOCATION_CONTEXT);
-                responseContext.put(Thread.currentThread(), resContext);
+                reloadResponseContext(resContext);
             }
             resList = CastUtils.cast(inMsg.getContent(List.class));
         }
@@ -822,9 +813,8 @@ public class ClientImpl
                                                 Message.INVOCATION_CONTEXT));
                         resCtx = CastUtils.cast((Map<?, ?>) resCtx
                                 .get(RESPONSE_CONTEXT));
-                        if (resCtx != null) {
-                            responseContext.put(Thread.currentThread(), resCtx);
-                        }
+                        resCtx = reloadResponseContext(resCtx);
+
                         // remove callback so that it won't be invoked twice
                         callback = message.getExchange().remove(ClientCallback.class);
                         if (callback != null) {
@@ -851,15 +841,14 @@ public class ClientImpl
                                                                 .getOutMessage()
                                                                 .get(Message.INVOCATION_CONTEXT));
                 resCtx = CastUtils.cast((Map<?, ?>)resCtx.get(RESPONSE_CONTEXT));
-                if (resCtx != null && responseContext != null) {
-                    responseContext.put(Thread.currentThread(), resCtx);
-                }
                 try {
                     Object obj[] = processResult(message, message.getExchange(),
                                                  null, resCtx);
 
+                    resCtx = reloadResponseContext(resCtx);
                     callback.handleResponse(resCtx, obj);
                 } catch (Throwable ex) {
+                    resCtx = reloadResponseContext(resCtx);
                     callback.handleException(resCtx, ex);
                 }
             }
@@ -1055,28 +1044,40 @@ public class ClientImpl
     }
 
 
-    /*
-     * modification are echoed back to the shared map
-     */
     public class EchoContext extends ConcurrentHashMap<String, Object> {
         private static final long serialVersionUID = 1L;
-        public EchoContext(Map<String, Object> sharedMap) {
+        
+        final Map<Thread, EchoContext> context;
+        public EchoContext(Map<String, Object> sharedMap, Map<Thread, EchoContext> ctx) {
+            super(8, 0.75f, 4);
+            if (sharedMap != null) {
+                super.putAll(sharedMap);
+            }
+            context = ctx;
+        }
+
+        public EchoContext(Map<Thread, EchoContext> ctx) {
             super(8, 0.75f, 4);
-            putAll(sharedMap);
+            context = ctx;
         }
 
         public void reload() {
+            reload(context.get(latestContextThread));
+        }
+        public void reload(Map<String, Object> content) {
             super.clear();
-            super.putAll(requestContext.get(latestContextThread));
+            if (content != null) {
+                putAll(content);
+            }
         }
         
         @Override
         public void clear() {
             super.clear();
             try {
-                for (Map.Entry<Thread, Map<String, Object>> ent : requestContext.entrySet()) {
+                for (Map.Entry<Thread, EchoContext> ent : context.entrySet()) {
                     if (ent.getValue() == this) {
-                        requestContext.remove(ent.getKey());
+                        context.remove(ent.getKey());
                         return;
                     }
                 }
@@ -1086,6 +1087,42 @@ public class ClientImpl
         }
     }
 
+    /** 
+     * Class to handle the response contexts.   The clear is overloaded to remove
+     * this context from the threadLocal caches in the ClientImpl
+     */
+    class ResponseContext extends HashMap<String, Object> {
+        private static final long serialVersionUID = 1L;
+        
+        ResponseContext(Map<String, Object> origMap) {
+            super(origMap);
+        }
+
+        ResponseContext() {
+        }
+
+        public void reload(Map<String, Object> content) {
+            super.clear();
+            if (content != null) {
+                putAll(content);
+            }
+        }
+        
+        @Override
+        public void clear() {
+            super.clear();
+            try {
+                for (Map.Entry<Thread, ResponseContext> ent : responseContext.entrySet()) {
+                    if (ent.getValue() == this) {
+                        responseContext.remove(ent.getKey());
+                        return;
+                    }
+                }
+            } catch (Throwable t) {
+                //ignore
+            }
+        }
+    }
 
     public void setExecutor(Executor executor) {
         if (!SynchronousExecutor.isA(executor)) {

-- 
To stop receiving notification emails like this one, please contact
dkulp@apache.org.

[cxf] 05/05: Generate a help mojo for the cxf-codegen-plugin, so the user can get help regarding goals and parameters from the command line. You can read more about how to use a help mojo here: https://maven.apache.org/plugin-tools/maven-plugin-plugin/help-mojo.html

Posted by dk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dkulp pushed a commit to branch 3.1.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit efe1df2b1abf3744caf2073d155064e67a6949f7
Author: Dennis Lundberg <de...@apache.org>
AuthorDate: Wed Mar 14 15:11:40 2018 +0100

    Generate a help mojo for the cxf-codegen-plugin, so the user can get help regarding goals and parameters from the command line.
    You can read more about how to use a help mojo here: https://maven.apache.org/plugin-tools/maven-plugin-plugin/help-mojo.html
    
    (cherry picked from commit 97e4a34d3fc07ec9c961c028e977c37a067cdd7d)
---
 maven-plugins/codegen-plugin/pom.xml | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/maven-plugins/codegen-plugin/pom.xml b/maven-plugins/codegen-plugin/pom.xml
index 7567d8d..90fa4f2 100644
--- a/maven-plugins/codegen-plugin/pom.xml
+++ b/maven-plugins/codegen-plugin/pom.xml
@@ -147,6 +147,12 @@
                             <goal>descriptor</goal>
                         </goals>
                     </execution>
+                    <execution>
+                        <id>generate-helpmojo</id>
+                        <goals>
+                            <goal>helpmojo</goal>
+                        </goals>
+                    </execution>
                 </executions>
             </plugin>
             <plugin>

-- 
To stop receiving notification emails like this one, please contact
dkulp@apache.org.

[cxf] 02/05: Recording .gitmergeinfo Changes

Posted by dk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dkulp pushed a commit to branch 3.1.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git

commit 1566ba6db001b6c1b05b177d824aae11f11c5e61
Author: Daniel Kulp <dk...@apache.org>
AuthorDate: Fri Apr 27 12:35:47 2018 -0400

    Recording .gitmergeinfo Changes
---
 .gitmergeinfo | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitmergeinfo b/.gitmergeinfo
index dfa48d6..4df41b6 100644
--- a/.gitmergeinfo
+++ b/.gitmergeinfo
@@ -1033,6 +1033,7 @@ M 66e97c77eaa43ab3a2cd95f0edc6a27e7445e8ce
 M 68ed35f4f1b3f550c547ab9ce6bd3a492228b332
 M 68f2489c40fc50ef14c7d69e78c0cbae82308cb0
 M 696287d157d5b89e8eff7ef4196cc46bdaa5ccb7
+M 6abad1864187457984b0dff2622eafb4b5df5305
 M 6becb31c62ef0845a5078f4ec2124fe7bc264e58
 M 6c746e0238ba136f9d8e1320138eeb7e4dda0480
 M 6ceb2e9862ae85cb884f2dc416911eff3bf22e87

-- 
To stop receiving notification emails like this one, please contact
dkulp@apache.org.