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:44:41 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes 7680385c3 -> b1808da98


[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/c5a9af5b
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/c5a9af5b
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/c5a9af5b

Branch: refs/heads/3.0.x-fixes
Commit: c5a9af5bac7b580658e164cde7cb417c3141428e
Parents: 0928b2f
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:44:15 2017 +0100

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


http://git-wip-us.apache.org/repos/asf/cxf/blob/c5a9af5b/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 3053e41..f9d5cd1 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
@@ -566,8 +566,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)))
{
@@ -587,7 +588,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/c5a9af5b/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 64e14ca..02b743d 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;
@@ -270,11 +271,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);
         }
     }
     
@@ -484,11 +481,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