cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r587537 - in /incubator/cxf/trunk: rt/core/src/main/java/org/apache/cxf/interceptor/ systests/src/test/java/org/apache/cxf/systest/jaxws/
Date Tue, 23 Oct 2007 15:18:21 GMT
Author: dkulp
Date: Tue Oct 23 08:18:17 2007
New Revision: 587537

URL: http://svn.apache.org/viewvc?rev=587537&view=rev
Log:
[CXF-1131] If getFaultInfo returns null, (xsi:nil=true on the wire), ClientFaultConverter
throws a NPE.

Modified:
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/Messages.properties
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ServiceTestFault.java

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java?rev=587537&r1=587536&r2=587537&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/ClientFaultConverter.java
Tue Oct 23 08:18:17 2007
@@ -24,6 +24,8 @@
 import java.util.List;
 import java.util.Map;
 import java.util.StringTokenizer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
@@ -33,6 +35,7 @@
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.databinding.DataBinding;
 import org.apache.cxf.databinding.DataReader;
@@ -53,6 +56,7 @@
  * @author Dan Diephouse
  */
 public class ClientFaultConverter extends AbstractPhaseInterceptor<Message> {
+    private static final Logger LOG = LogUtils.getLogger(ClientFaultConverter.class);
 
     public ClientFaultConverter() {
         super(Phase.UNMARSHAL);
@@ -118,16 +122,22 @@
         }
         
         if (!(e instanceof Exception)) {
-            Class<?> exClass = faultWanted.getProperty(Class.class.getName(), Class.class);
-            Class<?> beanClass = e.getClass();
+            
             try {
-                Constructor constructor = exClass.getConstructor(new Class[]{String.class,
beanClass});
-                e = constructor.newInstance(new Object[]{fault.getMessage(), e});
+                Class<?> exClass = faultWanted.getProperty(Class.class.getName(), Class.class);
+                if (e == null) { 
+                    Constructor constructor = exClass.getConstructor(new Class[]{String.class});
+                    e = constructor.newInstance(new Object[]{fault.getMessage()});
+                } else {
+                    Class<?> beanClass = e.getClass();
+                    Constructor constructor = exClass.getConstructor(new Class[]{String.class,
beanClass});
+                    e = constructor.newInstance(new Object[]{fault.getMessage(), e});
+                }
+                msg.setContent(Exception.class, e);
             } catch (Exception e1) {
-                throw new Fault(e1);
+                LogUtils.log(LOG, Level.INFO, "EXCEPTION_WHILE_CREATING_EXCEPTION", e1, e1.getMessage());
             }
         }
-        msg.setContent(Exception.class, e);
     }
 
     private boolean isDOMSupported(DataBinding db) {

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/Messages.properties?rev=587537&r1=587536&r2=587537&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/Messages.properties
(original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/Messages.properties
Tue Oct 23 08:18:17 2007
@@ -36,3 +36,5 @@
 COULD_NOT_CREATE_ANNOTATION_OBJECT=Could not create annotation object: {0}
 COULD_NOT_FIND_SEICLASS=Could not find the class: {0}
 EXCEPTION_WHILE_WRITING_FAULT = Exception occurred while writing fault.
+EXCEPTION_WHILE_CREATING_EXCEPTION = Exception occurred while creating exception: {0}
+ 

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java?rev=587537&r1=587536&r2=587537&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
Tue Oct 23 08:18:17 2007
@@ -311,6 +311,13 @@
         } catch (ServiceTestFault ex) {
             assertEquals(10, ex.getFaultInfo().getId());
         }
+        // CXF-1131 testcase
+        try {
+            port.throwException(-1);
+            fail("Expected exception not found");
+        } catch (ServiceTestFault ex) {
+            assertNull(ex.getFaultInfo());
+        }
     }
     
     

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java?rev=587537&r1=587536&r2=587537&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/DocLitWrappedCodeFirstServiceImpl.java
Tue Oct 23 08:18:17 2007
@@ -119,6 +119,9 @@
     }
    
     public int throwException(int i) throws ServiceTestFault {
+        if (i == -1) {
+            throw new ServiceTestFault("Hello!");
+        }
         throw new ServiceTestFault(new ServiceTestFault.ServiceTestDetails(i));
     }
     

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ServiceTestFault.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ServiceTestFault.java?rev=587537&r1=587536&r2=587537&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ServiceTestFault.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ServiceTestFault.java
Tue Oct 23 08:18:17 2007
@@ -24,6 +24,10 @@
 @WebFault()
 public class ServiceTestFault extends Exception {
     private ServiceTestDetails details;
+    
+    public ServiceTestFault(String msg) {
+        super(msg);
+    }
     public ServiceTestFault(String msg, ServiceTestDetails details) {
         super(msg);
         this.details = details;



Mime
View raw message