cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject cxf git commit: [CXF-6657] Making ResponseExceptionMapper work with FailoverFeature, patch from Florian Léger applied with tiny modifications
Date Fri, 30 Oct 2015 12:14:16 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes dcec2eee1 -> 6becd2b95


[CXF-6657] Making ResponseExceptionMapper work with FailoverFeature, patch from Florian Léger
applied with tiny modifications


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

Branch: refs/heads/3.0.x-fixes
Commit: 6becd2b9544cca83e7ff8d17a4b0ae07f097ae55
Parents: dcec2ee
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Fri Oct 30 11:55:22 2015 +0000
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Fri Oct 30 12:13:58 2015 +0000

----------------------------------------------------------------------
 .../cxf/clustering/FailoverTargetSelector.java  | 21 ++++++++++++--------
 .../apache/cxf/jaxrs/client/AbstractClient.java | 18 ++++++++++++-----
 .../apache/cxf/transport/http/HTTPConduit.java  |  7 +++----
 3 files changed, 29 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/6becd2b9/rt/features/clustering/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
----------------------------------------------------------------------
diff --git a/rt/features/clustering/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
b/rt/features/clustering/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
index 722beab..61fce66 100644
--- a/rt/features/clustering/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
+++ b/rt/features/clustering/src/main/java/org/apache/cxf/clustering/FailoverTargetSelector.java
@@ -47,8 +47,10 @@ import org.apache.cxf.transport.Conduit;
  */
 public class FailoverTargetSelector extends AbstractConduitSelector {
 
-    private static final Logger LOG =
-        LogUtils.getL7dLogger(FailoverTargetSelector.class);
+    private static final Logger LOG = LogUtils.getL7dLogger(FailoverTargetSelector.class);
+    private static final String COMPLETE_IF_SERVICE_NOT_AVAIL_PROPERTY = 
+        "org.apache.cxf.transport.complete_if_service_not_available";
+
     protected ConcurrentHashMap<InvocationKey, InvocationContext> inProgress 
         = new ConcurrentHashMap<InvocationKey, InvocationContext>();
     protected FailoverStrategy failoverStrategy;
@@ -99,7 +101,10 @@ public class FailoverTargetSelector extends AbstractConduitSelector {
     }
 
     protected void setupExchangeExceptionProperties(Exchange ex) {
-        ex.remove("org.apache.cxf.transport.no_io_exceptions");
+        if (!isSupportNotAvailableErrorsOnly()) {
+            ex.remove("org.apache.cxf.transport.no_io_exceptions");
+        }
+        ex.put(COMPLETE_IF_SERVICE_NOT_AVAIL_PROPERTY, true);
     }
     
     /**
@@ -144,6 +149,7 @@ public class FailoverTargetSelector extends AbstractConduitSelector {
                 removeConduit(old);
                 failover = performFailover(exchange, invocation);
             } else {
+                exchange.remove(COMPLETE_IF_SERVICE_NOT_AVAIL_PROPERTY);
                 setOriginalEndpoint(invocation);
             }
         } else {
@@ -273,12 +279,11 @@ public class FailoverTargetSelector extends AbstractConduitSelector
{
                             "CHECK_FAILURE_IN_TRANSPORT",
                             new Object[] {ex, failover});
         }
-        if (failover 
-            && isSupportNotAvailableErrorsOnly()
-            && exchange.get(Message.RESPONSE_CODE) != null
-            && !PropertyUtils.isTrue(exchange.get("org.apache.cxf.transport.service_not_available")))
{ 
-            failover = false;
+
+        if (isSupportNotAvailableErrorsOnly() && exchange.get(Message.RESPONSE_CODE)
!= null) {
+            failover = PropertyUtils.isTrue(exchange.get("org.apache.cxf.transport.service_not_available"));
         }
+
         return failover;
     }
     

http://git-wip-us.apache.org/repos/asf/cxf/blob/6becd2b9/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
----------------------------------------------------------------------
diff --git a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
index a25d0f7..cb74ed8 100644
--- a/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
+++ b/rt/rs/client/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
@@ -58,6 +58,7 @@ import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.common.util.PropertyUtils;
 import org.apache.cxf.endpoint.ClientLifeCycleManager;
 import org.apache.cxf.endpoint.ConduitSelector;
 import org.apache.cxf.endpoint.Endpoint;
@@ -106,8 +107,11 @@ public abstract class AbstractClient implements Client {
     protected static final String HTTP_SCHEME = "http";
     
     private static final String PROXY_PROPERTY = "jaxrs.proxy";
-    private static final String HEADER_SPLIT_PROPERTY =
-        "org.apache.cxf.http.header.split";
+    private static final String HEADER_SPLIT_PROPERTY = "org.apache.cxf.http.header.split";
+    private static final String SERVICE_NOT_AVAIL_PROPERTY = "org.apache.cxf.transport.service_not_available";
+    private static final String COMPLETE_IF_SERVICE_NOT_AVAIL_PROPERTY = 
+        "org.apache.cxf.transport.complete_if_service_not_available";
+    
     private static final Logger LOG = LogUtils.getL7dLogger(AbstractClient.class);
     private static final Set<String> KNOWN_METHODS = new HashSet<String>(
         Arrays.asList("GET", "POST", "HEAD", "OPTIONS", "PUT", "DELETE", "TRACE"));
@@ -551,13 +555,17 @@ public abstract class AbstractClient implements Client {
         Exchange exchange = message.getExchange(); 
       
         Exception ex = message.getContent(Exception.class);
-        if (ex != null) {
+        if (ex != null
+            || PropertyUtils.isTrue(exchange.get(SERVICE_NOT_AVAIL_PROPERTY))
+                && PropertyUtils.isTrue(exchange.get(COMPLETE_IF_SERVICE_NOT_AVAIL_PROPERTY)))
{
             getConfiguration().getConduitSelector().complete(exchange);
+        }
+        if (ex != null) {
             checkClientException(message, ex);
         }
-        checkClientException(message, message.getExchange().get(Exception.class));
+        checkClientException(message, exchange.get(Exception.class));
         
-        List<?> result = message.getExchange().get(List.class);
+        List<?> result = exchange.get(List.class);
         return result != null ? result.toArray() : null;
     }
     

http://git-wip-us.apache.org/repos/asf/cxf/blob/6becd2b9/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
----------------------------------------------------------------------
diff --git a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
index 49aca3f..83e5960 100644
--- a/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
+++ b/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
@@ -1565,6 +1565,9 @@ public abstract class HTTPConduit
             }
             if (exchange != null) {
                 exchange.put(Message.RESPONSE_CODE, rc);
+                if (rc == 404 || rc == 503) {
+                    exchange.put("org.apache.cxf.transport.service_not_available", true);
+                } 
             }
                        
             // "org.apache.cxf.transport.no_io_exceptions" property should be set in case
the exceptions
@@ -1578,10 +1581,6 @@ public abstract class HTTPConduit
                 && (rc > 400 || !MessageUtils.isTrue(outMessage
                     .getContextualProperty("org.apache.cxf.transport.process_fault_on_http_400"))))
{
 
-                if (rc == 404 || rc == 503) {
-                    exchange.put("org.apache.cxf.transport.service_not_available", true);
-                }
-
                 throw new HTTPException(rc, getResponseMessage(), url.toURL());
             }
             return rc;


Mime
View raw message