cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1533037 - in /cxf/branches/2.7.x-fixes: ./ rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/ rt/transports/local/src/main/java/org/apache/cxf/transport/local/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
Date Thu, 17 Oct 2013 10:42:58 GMT
Author: sergeyb
Date: Thu Oct 17 10:42:58 2013
New Revision: 1533037

URL: http://svn.apache.org/r1533037
Log:
Merged revisions 1532865,1532871,1532892 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1532865 | dkulp | 2013-10-16 20:14:50 +0100 (Wed, 16 Oct 2013) | 1 line
  
  Get empty responses being sent back with local transport
........
  r1532871 | dkulp | 2013-10-16 20:25:50 +0100 (Wed, 16 Oct 2013) | 1 line
  
  If the dispatch throws an excpetion (likely from the fault out chain), try to do something
smart with it.
........
  r1532892 | sergeyb | 2013-10-16 21:28:49 +0100 (Wed, 16 Oct 2013) | 1 line
  
  Adding more local transport tests
........

Modified:
    cxf/branches/2.7.x-fixes/   (props changed)
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
    cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutExceptionMapperInterceptor.java
    cxf/branches/2.7.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java
    cxf/branches/2.7.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java
    cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
    cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
  Merged /cxf/trunk:r1532865-1532871,1532892

Propchange: cxf/branches/2.7.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java?rev=1533037&r1=1533036&r2=1533037&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
Thu Oct 17 10:42:58 2013
@@ -292,8 +292,11 @@ public class JAXRSInInterceptor extends 
         Object mapProp = message.getContextualProperty("map.cxf.interceptor.fault");
         if (MessageUtils.isTrue(mapProp)) {
         
-            Response r = JAXRSUtils.convertFaultToResponse(message.getContent(Exception.class),

-                                                           message);
+            Throwable ex = message.getContent(Exception.class);
+            if (ex instanceof Fault) {
+                ex = ((Fault)ex).getCause();
+            }
+            Response r = JAXRSUtils.convertFaultToResponse(ex, message);
             if (r != null) {
                 message.removeContent(Exception.class);
                 message.getInterceptorChain().setFaultObserver(null);

Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutExceptionMapperInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutExceptionMapperInterceptor.java?rev=1533037&r1=1533036&r2=1533037&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutExceptionMapperInterceptor.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSOutExceptionMapperInterceptor.java
Thu Oct 17 10:42:58 2013
@@ -58,8 +58,11 @@ public class JAXRSOutExceptionMapperInte
             return;
         }
         
-        Response r = JAXRSUtils.convertFaultToResponse(message.getContent(Exception.class),

-                                                       message);
+        Throwable ex = message.getContent(Exception.class);
+        if (ex instanceof Fault) {
+            ex = ((Fault)ex).getCause();
+        }
+        Response r = JAXRSUtils.convertFaultToResponse(ex, message);
         if (r != null) {
             message.removeContent(Exception.class);
             message.getInterceptorChain().setFaultObserver(null);

Modified: cxf/branches/2.7.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java?rev=1533037&r1=1533036&r2=1533037&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalConduit.java
Thu Oct 17 10:42:58 2013
@@ -24,6 +24,8 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.PipedInputStream;
 import java.io.PipedOutputStream;
+import java.util.HashMap;
+import java.util.List;
 import java.util.concurrent.Executor;
 import java.util.logging.Logger;
 
@@ -80,7 +82,24 @@ public class LocalConduit extends Abstra
                     ex.setInMessage(inMsg);
                     inMsg.setExchange(ex);
                     ex.put(IN_EXCHANGE, exchange);
-                    destination.getMessageObserver().onMessage(inMsg);
+                    try {
+                        destination.getMessageObserver().onMessage(inMsg);
+                    } catch (Throwable t) {
+                        Message m = inMsg.getExchange().getOutFaultMessage();
+                        if (m == null) {
+                            m = inMsg.getExchange().getOutMessage();
+                        }
+                        if (m != null) {
+                            try {
+                                m.put(Message.RESPONSE_CODE, 500);
+                                m.put(Message.PROTOCOL_HEADERS, new HashMap<String, List<String>>());
+                                m.getExchange().put(Message.RESPONSE_CODE, 500);
+                                m.getContent(OutputStream.class).close();
+                            } catch (IOException e) {
+                                //ignore
+                            }
+                        }
+                    }
                 }
             };
             Executor ex = message.getExchange() != null

Modified: cxf/branches/2.7.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java?rev=1533037&r1=1533036&r2=1533037&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java
(original)
+++ cxf/branches/2.7.x-fixes/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java
Thu Oct 17 10:42:58 2013
@@ -70,6 +70,59 @@ public class LocalDestination extends Ab
     }
 
     class SynchronousConduit extends AbstractConduit {
+        private final class LocalDestinationOutputStream extends AbstractWrappedOutputStream
{
+            private final Exchange exchange;
+            private final Message message;
+
+            private LocalDestinationOutputStream(Exchange exchange, Message message) {
+                this.exchange = exchange;
+                this.message = message;
+            }
+
+            public void close() throws IOException {
+                if (!written) {
+                    dispatchToClient(true);
+                }
+                super.close();
+            }
+
+            protected void onFirstWrite() throws IOException {
+                dispatchToClient(false);
+            }
+
+            protected void dispatchToClient(boolean empty) throws IOException {
+                final MessageImpl m = new MessageImpl();
+                localDestinationFactory.copy(message, m);
+                if (!empty) {
+                    final PipedInputStream stream = new PipedInputStream();
+                    wrappedStream = new PipedOutputStream(stream);
+                    m.setContent(InputStream.class, stream);
+                }
+
+                final Runnable receiver = new Runnable() {
+                    public void run() {                                    
+                        if (exchange != null) {
+                            exchange.setInMessage(m);
+                        }
+                        conduit.getMessageObserver().onMessage(m);
+                    }
+                };
+                Executor ex = message.getExchange() != null
+                    ? message.getExchange().get(Executor.class) : null;
+                // Need to avoid to get the SynchronousExecutor
+                if (ex == null || SynchronousExecutor.isA(ex)) {
+                    ex = localDestinationFactory.getExecutor();
+                    if (ex != null) {
+                        ex.execute(receiver);
+                    } else {
+                        new Thread(receiver).start();
+                    }
+                } else {
+                    ex.execute(receiver);
+                }
+            }
+        }
+
         private LocalConduit conduit;
 
         public SynchronousConduit(LocalConduit conduit) {
@@ -82,38 +135,7 @@ public class LocalDestination extends Ab
                 final Exchange exchange = (Exchange)message.getExchange().get(LocalConduit.IN_EXCHANGE);
 
                 AbstractWrappedOutputStream cout 
-                    = new AbstractWrappedOutputStream() {
-                        protected void onFirstWrite() throws IOException {
-                            final PipedInputStream stream = new PipedInputStream();
-                            wrappedStream = new PipedOutputStream(stream);
-
-                            final MessageImpl m = new MessageImpl();
-                            localDestinationFactory.copy(message, m);
-                            m.setContent(InputStream.class, stream);
-
-                            final Runnable receiver = new Runnable() {
-                                public void run() {                                    
-                                    if (exchange != null) {
-                                        exchange.setInMessage(m);
-                                    }
-                                    conduit.getMessageObserver().onMessage(m);
-                                }
-                            };
-                            Executor ex = message.getExchange() != null
-                                ? message.getExchange().get(Executor.class) : null;
-                            // Need to avoid to get the SynchronousExecutor
-                            if (ex == null || SynchronousExecutor.isA(ex)) {
-                                ex = localDestinationFactory.getExecutor();
-                                if (ex != null) {
-                                    ex.execute(receiver);
-                                } else {
-                                    new Thread(receiver).start();
-                                }
-                            } else {
-                                ex.execute(receiver);
-                            }
-                        }
-                    };
+                    = new LocalDestinationOutputStream(exchange, message);
                 
                 message.setContent(OutputStream.class, cout);    
                 

Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java?rev=1533037&r1=1533036&r2=1533037&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
Thu Oct 17 10:42:58 2013
@@ -502,6 +502,12 @@ public class BookStore {
     }
     
     @GET
+    @Path("infault2")
+    public Response infault2() {
+        throw new RuntimeException();
+    }
+
+    @GET
     @Path("outfault")
     public Response outfault() {
         return Response.ok().build();

Modified: cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java?rev=1533037&r1=1533036&r2=1533037&view=diff
==============================================================================
--- cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
(original)
+++ cxf/branches/2.7.x-fixes/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
Thu Oct 17 10:42:58 2013
@@ -40,7 +40,6 @@ import org.apache.cxf.transport.local.Lo
 
 import org.junit.After;
 import org.junit.Before;
-import org.junit.Ignore;
 import org.junit.Test;
 
 public class JAXRSLocalTransportTest extends AbstractBusClientServerTestBase {
@@ -59,6 +58,10 @@ public class JAXRSLocalTransportTest ext
         outInts.add(new CustomOutInterceptor());
         sf.setOutInterceptors(outInts);
         
+        List<Interceptor<? extends Message>> inInts = new ArrayList<Interceptor<?
extends Message>>();
+        inInts.add(new CustomInFaultyInterceptor());
+        sf.setInInterceptors(inInts);
+        
         sf.setTransportId(LocalTransportFactory.TRANSPORT_ID);
         sf.setAddress("local://books");
         localServer = sf.create();
@@ -80,10 +83,16 @@ public class JAXRSLocalTransportTest ext
     }
     
     @Test
-    @Ignore
-    public void testProxyServerInFault() throws Exception {
+    public void testProxyServerInFaultMapped() throws Exception {
         BookStore localProxy = JAXRSClientFactory.create("local://books", BookStore.class);
         Response r = localProxy.infault();
+        assertEquals(401, r.getStatus());
+    }
+    
+    @Test
+    public void testProxyServerInFaultEscaped() throws Exception {
+        BookStore localProxy = JAXRSClientFactory.create("local://books", BookStore.class);
+        Response r = localProxy.infault2();
         assertEquals(500, r.getStatus());
     }
     
@@ -92,12 +101,11 @@ public class JAXRSLocalTransportTest ext
         BookStore localProxy = JAXRSClientFactory.create("local://books", BookStore.class);
         WebClient.getConfig(localProxy).getRequestContext().put(LocalConduit.DIRECT_DISPATCH,
"true");
         WebClient.getConfig(localProxy).getInFaultInterceptors().add(new TestFaultInInterceptor());
-        Response r = localProxy.infault();
+        Response r = localProxy.infault2();
         assertEquals(500, r.getStatus());
     }
     
     @Test
-    @Ignore
     public void testProxyEmtpyResponse() throws Exception {
         BookStore localProxy = JAXRSClientFactory.create("local://books", BookStore.class);
         assertNull(localProxy.getEmptyBook());



Mime
View raw message