cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: Making it simpler to enable auto-closing for JAX-RS 2.0 clients
Date Tue, 11 Aug 2015 16:28:22 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 7523f6f9e -> 961362dec


Making it simpler to enable auto-closing for JAX-RS 2.0 clients


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

Branch: refs/heads/3.0.x-fixes
Commit: 961362decec21acc5ca37cc86734d141f4839b6c
Parents: 7523f6f
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Tue Aug 11 15:58:41 2015 +0100
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Tue Aug 11 17:28:05 2015 +0100

----------------------------------------------------------------------
 .../apache/cxf/jaxrs/client/spec/ClientImpl.java | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/961362de/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/spec/ClientImpl.java
----------------------------------------------------------------------
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 b15d730..52e900f 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
@@ -39,7 +39,6 @@ import javax.ws.rs.core.Link;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.UriBuilder;
 
-import org.apache.cxf.common.util.PropertyUtils;
 import org.apache.cxf.configuration.jsse.TLSClientParameters;
 import org.apache.cxf.jaxrs.client.ClientConfiguration;
 import org.apache.cxf.jaxrs.client.ClientProviderFactory;
@@ -54,6 +53,7 @@ public class ClientImpl implements Client {
     private static final String HTTP_PROXY_SERVER_PROP = "http.proxy.server.uri";
     private static final String HTTP_PROXY_SERVER_PORT_PROP = "http.proxy.server.port";
     private static final String HTTP_AUTOREDIRECT_PROP = "http.autoredirect";
+    private static final String HTTP_RESPONSE_AUTOCLOSE_PROP = "http.response.stream.auto.close";
     
     private Configurable<Client> configImpl;
     private TLSConfiguration secConfig;
@@ -273,6 +273,12 @@ public class ClientImpl implements Client {
             clientCfg.getRequestContext().put(Client.class.getName(), ClientImpl.this);
             clientCfg.getRequestContext().put(Configuration.class.getName(), 
                                                                       getConfiguration());
+            
+            // Response auto-close
+            Boolean responseAutoClose = getBooleanValue(configProps.get(HTTP_RESPONSE_AUTOCLOSE_PROP));
+            if (responseAutoClose != null) {
+                clientCfg.getResponseContext().put("response.stream.auto.close", responseAutoClose);
+            }
             // TLS
             TLSClientParameters tlsParams = secConfig.getTlsClientParams();
             if (tlsParams.getSSLSocketFactory() != null 
@@ -305,9 +311,9 @@ public class ClientImpl implements Client {
             if (proxyServerPortValue != null) {
                 clientCfg.getHttpConduit().getClient().setProxyServerPort(proxyServerPortValue);
             }
-            Object autoRedirectValue = configProps.get(HTTP_AUTOREDIRECT_PROP);
-            if (PropertyUtils.isTrue(autoRedirectValue)) {
-                clientCfg.getHttpConduit().getClient().setAutoRedirect(true);
+            Boolean autoRedirectValue = getBooleanValue(configProps.get(HTTP_AUTOREDIRECT_PROP));
+            if (autoRedirectValue != null) {
+                clientCfg.getHttpConduit().getClient().setAutoRedirect(autoRedirectValue);
             }
         }
 
@@ -386,7 +392,7 @@ public class ClientImpl implements Client {
             checkNull(name, value);
             return newWebTarget(getUriBuilder().resolveTemplate(name, value, encodeSlash));
         }
-
+        
         @Override
         public WebTarget resolveTemplateFromEncoded(String name, Object value) {
             checkNull(name, value);
@@ -514,4 +520,7 @@ public class ClientImpl implements Client {
     private static Integer getIntValue(Object o) {
         return o instanceof Integer ? (Integer)o : o instanceof String ? Integer.valueOf(o.toString())
: null;
     }
+    private static Boolean getBooleanValue(Object o) {
+        return o instanceof Boolean ? (Boolean)o : o instanceof Boolean ? Boolean.valueOf(o.toString())
: null;
+    }
 }


Mime
View raw message