cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject [1/2] cxf git commit: [CXF-7301] Trying to catch the in exceptions with the status less than 300 (the higher-value status will generate an exception)
Date Mon, 27 Mar 2017 11:32:22 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.1.x-fixes 4816a975b -> 3a14d3852


[CXF-7301] Trying to catch the in exceptions with the status less than 300 (the higher-value
status will generate an exception)


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

Branch: refs/heads/3.1.x-fixes
Commit: 95fb948cb8b008791028c5c36db700722ca2e0d1
Parents: fd28dc9
Author: Sergey Beryozkin <sberyozkin@gmail.com>
Authored: Mon Mar 27 12:26:34 2017 +0100
Committer: Sergey Beryozkin <sberyozkin@gmail.com>
Committed: Mon Mar 27 12:31:55 2017 +0100

----------------------------------------------------------------------
 .../org/apache/cxf/jaxrs/client/AbstractClient.java    |  7 +++++--
 .../systest/jaxrs/security/xml/JAXRSXmlSecTest.java    | 13 +++----------
 2 files changed, 8 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/95fb948c/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 8dfeb6e..30e032f 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
@@ -568,7 +568,9 @@ public abstract class AbstractClient implements Client {
                 }
             }
         }
-        ex = message.getContent(Exception.class);
+        if (ex == null) {
+            ex = message.getContent(Exception.class);
+        }
         if (ex != null
             || PropertyUtils.isTrue(exchange.get(SERVICE_NOT_AVAIL_PROPERTY))
                 && PropertyUtils.isTrue(exchange.get(COMPLETE_IF_SERVICE_NOT_AVAIL_PROPERTY)))
{
@@ -588,7 +590,8 @@ public abstract class AbstractClient implements Client {
         
         Exchange exchange = outMessage.getExchange();
         Integer responseCode = getResponseCode(exchange);
-        if (responseCode == null 
+        if (responseCode == null
+            || responseCode < 300 && !(actualEx instanceof IOException) 
             || actualEx instanceof IOException && exchange.get("client.redirect.exception")
!= null) {
             if (actualEx instanceof ProcessingException) {
                 throw (RuntimeException)actualEx;

http://git-wip-us.apache.org/repos/asf/cxf/blob/95fb948c/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java
----------------------------------------------------------------------
diff --git a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java
b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java
index f1b22c3..b1c42d8 100644
--- a/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java
+++ b/systests/rs-security/src/test/java/org/apache/cxf/systest/jaxrs/security/xml/JAXRSXmlSecTest.java
@@ -45,6 +45,7 @@ import org.apache.cxf.systest.jaxrs.security.Book;
 import org.apache.cxf.systest.jaxrs.security.BookStore;
 import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
 import org.apache.xml.security.encryption.XMLCipher;
+
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -305,11 +306,7 @@ public class JAXRSXmlSecTest extends AbstractBusClientServerTestBase
{
         } catch (WebApplicationException ex) {
             fail(ex.getMessage());
         } catch (ProcessingException ex) {
-            if (ex.getCause() != null && ex.getCause().getMessage() != null) {
-                fail(ex.getCause().getMessage());
-            } else {
-                fail(ex.getMessage());
-            }
+            assertTrue(ex.getCause() instanceof BadRequestException);
         }
     }
     
@@ -519,11 +516,7 @@ public class JAXRSXmlSecTest extends AbstractBusClientServerTestBase
{
                 fail(ex.getMessage());
             }
         } catch (ProcessingException ex) {
-            if (ex.getCause() != null && ex.getCause().getMessage() != null) {
-                fail(ex.getCause().getMessage());
-            } else {
-                fail(ex.getMessage());
-            }
+            assertTrue(ex.getCause() instanceof BadRequestException);
         }
         
     }


Mime
View raw message