cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [01/10] git commit: [CXF-5968] Make sure the old true/false values for the Async policy still work
Date Tue, 07 Oct 2014 18:46:13 GMT
Repository: cxf
Updated Branches:
  refs/heads/2.7.x-fixes 5489c942f -> c0a179ca5


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

Conflicts:
	rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduit.java
	rt/transports/http-hc/src/main/java/org/apache/cxf/transport/http/asyncclient/AsyncHTTPConduitFactory.java
	rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduit.java
	rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduitFactory.java


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

Branch: refs/heads/2.7.x-fixes
Commit: 107bfdab25d654a9291dc05bf241c8aca24e933a
Parents: 5489c94
Author: Daniel Kulp <dkulp@apache.org>
Authored: Fri Aug 29 11:54:59 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Tue Oct 7 13:18:26 2014 -0400

----------------------------------------------------------------------
 .../http/asyncclient/AsyncHTTPConduit.java      | 31 ++++++++-----------
 .../asyncclient/AsyncHTTPConduitFactory.java    | 32 ++++++++++++++------
 2 files changed, 36 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/107bfdab/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 48d3983..e4d8b22 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
@@ -138,25 +138,20 @@ 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;
+        }
             
-        } 
-        if (uri.getScheme().equals("https") 
+        if (uri.getScheme().equals("https")
             && tlsClientParameters != null
             && tlsClientParameters.getSSLSocketFactory() != null) {
             //if they configured in an SSLSocketFactory, we cannot do anything

http://git-wip-us.apache.org/repos/asf/cxf/blob/107bfdab/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 e516e98..06cfa9e 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
@@ -108,7 +108,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;
+        }
     };
         
     
@@ -191,14 +212,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);
-        } 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);


Mime
View raw message