cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject git commit: [CXF-5968] Make sure the old true/false values for the Async policy still work
Date Fri, 29 Aug 2014 15:58:47 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes d84e03f7f -> e2be25572


[CXF-5968] Make sure the old true/false values for the Async policy still work


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/e2be2557
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/e2be2557
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/e2be2557

Branch: refs/heads/3.0.x-fixes
Commit: e2be25572d59a5c3ec3ff333d9a1641c1f3a2e6c
Parents: d84e03f
Author: Daniel Kulp <dkulp@apache.org>
Authored: Fri Aug 29 11:54:59 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Fri Aug 29 11:58:21 2014 -0400

----------------------------------------------------------------------
 .../http/asyncclient/AsyncHTTPConduit.java      | 29 ++++++++----------
 .../asyncclient/AsyncHTTPConduitFactory.java    | 32 ++++++++++++++------
 .../http/netty/client/NettyHttpConduit.java     | 29 ++++++++----------
 .../netty/client/NettyHttpConduitFactory.java   | 32 ++++++++++++++------
 4 files changed, 70 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/e2be2557/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
----------------------------------------------------------------------
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 d1d6abd..57c9a42 100644
--- 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
@@ -149,24 +149,19 @@ public class AsyncHTTPConduit extends URLConnectionHTTPConduit {
         if (o == null) {
             o = factory.getUseAsyncPolicy();
         }
-        if (o instanceof String) {
-            o = UseAsyncPolicy.valueOf(o.toString().toUpperCase());
-        }
-        if (o instanceof UseAsyncPolicy) {
-            switch ((UseAsyncPolicy)o) {
-            case ALWAYS:
-                o = true;
-                break;
-            case NEVER:
-                o = false;
-                break;
-            case ASYNC_ONLY:
-            default:
-                o = !message.getExchange().isSynchronous();
-                break;
-            }
-            
+        switch (UseAsyncPolicy.getPolicy(o)) {
+        case ALWAYS:
+            o = true;
+            break;
+        case NEVER:
+            o = false;
+            break;
+        case ASYNC_ONLY:
+        default:
+            o = !message.getExchange().isSynchronous();
+            break;
         }
+            
         // check tlsClientParameters from message header
         TLSClientParameters clientParameters = message.get(TLSClientParameters.class);
         if (clientParameters == null) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/e2be2557/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitFactory.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitFactory.java
b/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitFactory.java
index d836c9f..c8411c9 100644
--- a/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitFactory.java
+++ b/rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitFactory.java
@@ -88,7 +88,28 @@ public class AsyncHTTPConduitFactory implements HTTPConduitFactory {
     
     
     public static enum UseAsyncPolicy {
-        ALWAYS, ASYNC_ONLY, NEVER
+        ALWAYS, ASYNC_ONLY, NEVER;
+        
+        public static UseAsyncPolicy getPolicy(Object st) {
+            if (st instanceof UseAsyncPolicy) {
+                return (UseAsyncPolicy)st;
+            } else if (st instanceof String) {
+                String s = ((String)st).toUpperCase();
+                if ("ALWAYS".equals(s)) {
+                    return ALWAYS;
+                } else if ("NEVER".equals(s)) {
+                    return NEVER;
+                } else if ("ASYNC_ONLY".equals(s)) {
+                    return ASYNC_ONLY;
+                } else {
+                    st = Boolean.parseBoolean(s);
+                }
+            }
+            if (st instanceof Boolean) {
+                return ((Boolean)st).booleanValue() ? ALWAYS : NEVER;
+            }
+            return ASYNC_ONLY;
+        }
     };
         
     volatile PoolingNHttpClientConnectionManager connectionManager;
@@ -150,14 +171,7 @@ public class AsyncHTTPConduitFactory implements HTTPConduitFactory {
         if (st == null) {
             st = SystemPropertyAction.getPropertyOrNull(USE_POLICY);
         }
-        if (st instanceof UseAsyncPolicy) {
-            policy = (UseAsyncPolicy)st;
-        } else if (st instanceof String) {
-            policy = UseAsyncPolicy.valueOf(((String)st).toUpperCase());
-        } else {
-            //policy = UseAsyncPolicy.ALWAYS;
-            policy = UseAsyncPolicy.ASYNC_ONLY;
-        }
+        policy = UseAsyncPolicy.getPolicy(st);
         
         maxConnections = getInt(s.get(MAX_CONNECTIONS), maxConnections);
         connectionTTL = getInt(s.get(CONNECTION_TTL), connectionTTL);

http://git-wip-us.apache.org/repos/asf/cxf/blob/e2be2557/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduit.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduit.java
b/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduit.java
index 6ad870e..c5006a3 100644
--- a/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduit.java
+++ b/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduit.java
@@ -113,24 +113,19 @@ public class NettyHttpConduit extends URLConnectionHTTPConduit implements
BusLif
         if (o == null) {
             o = factory.getUseAsyncPolicy();
         }
-        if (o instanceof String) {
-            o = NettyHttpConduitFactory.UseAsyncPolicy.valueOf(o.toString().toUpperCase());
-        }
-        if (o instanceof NettyHttpConduitFactory.UseAsyncPolicy) {
-            switch ((NettyHttpConduitFactory.UseAsyncPolicy)o) {
-            case ALWAYS:
-                o = true;
-                break;
-            case NEVER:
-                o = false;
-                break;
-            case ASYNC_ONLY:
-            default:
-                o = !message.getExchange().isSynchronous();
-                break;
-            }
-            
+        switch (NettyHttpConduitFactory.UseAsyncPolicy.getPolicy(o)) {
+        case ALWAYS:
+            o = true;
+            break;
+        case NEVER:
+            o = false;
+            break;
+        case ASYNC_ONLY:
+        default:
+            o = !message.getExchange().isSynchronous();
+            break;
         }
+            
         // check tlsClientParameters from message header
         TLSClientParameters clientParameters = message.get(TLSClientParameters.class);
         if (clientParameters == null) {

http://git-wip-us.apache.org/repos/asf/cxf/blob/e2be2557/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduitFactory.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduitFactory.java
b/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduitFactory.java
index 4ab27b8..c07f9bb 100644
--- a/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduitFactory.java
+++ b/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduitFactory.java
@@ -41,20 +41,34 @@ public class NettyHttpConduitFactory implements HTTPConduitFactory {
     public static final String USE_POLICY = "org.apache.cxf.transport.http.netty.usePolicy";
     
     public static enum UseAsyncPolicy {
-        ALWAYS, ASYNC_ONLY, NEVER
+        ALWAYS, ASYNC_ONLY, NEVER;
+        
+        public static UseAsyncPolicy getPolicy(Object st) {
+            if (st instanceof UseAsyncPolicy) {
+                return (UseAsyncPolicy)st;
+            } else if (st instanceof String) {
+                String s = ((String)st).toUpperCase();
+                if ("ALWAYS".equals(s)) {
+                    return ALWAYS;
+                } else if ("NEVER".equals(s)) {
+                    return NEVER;
+                } else if ("ASYNC_ONLY".equals(s)) {
+                    return ASYNC_ONLY;
+                } else {
+                    st = Boolean.parseBoolean(s);
+                }
+            }
+            if (st instanceof Boolean) {
+                return ((Boolean)st).booleanValue() ? ALWAYS : NEVER;
+            }
+            return ASYNC_ONLY;
+        }
     };
     
     UseAsyncPolicy policy;
     public NettyHttpConduitFactory() {
         Object st = SystemPropertyAction.getPropertyOrNull(USE_POLICY);
-        if (st instanceof UseAsyncPolicy) {
-            policy = (UseAsyncPolicy)st;
-        } else if (st instanceof String) {
-            policy = UseAsyncPolicy.valueOf(((String)st).toUpperCase());
-        } else {
-            //policy = UseAsyncPolicy.ALWAYS;
-            policy = UseAsyncPolicy.ASYNC_ONLY;
-        }        
+        policy = UseAsyncPolicy.getPolicy(st);
     }
     
     public UseAsyncPolicy getUseAsyncPolicy() {


Mime
View raw message