cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1532865 - in /cxf/trunk: rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
Date Wed, 16 Oct 2013 19:14:51 GMT
Author: dkulp
Date: Wed Oct 16 19:14:50 2013
New Revision: 1532865

URL: http://svn.apache.org/r1532865
Log:
Get empty responses being sent back with local transport

Modified:
    cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java

Modified: cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java?rev=1532865&r1=1532864&r2=1532865&view=diff
==============================================================================
--- cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java
(original)
+++ cxf/trunk/rt/transports/local/src/main/java/org/apache/cxf/transport/local/LocalDestination.java
Wed Oct 16 19:14:50 2013
@@ -76,6 +76,63 @@ 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)) {
+                    if (exchange == null) {
+                        ex = localDestinationFactory.getExecutor(bus);
+                    } else {
+                        ex = localDestinationFactory.getExecutor(exchange.getBus());
+                    }
+                    if (ex != null) {
+                        ex.execute(receiver);
+                    } else {
+                        new Thread(receiver).start();
+                    }
+                } else {
+                    ex.execute(receiver);
+                }
+            }
+        }
+
         private LocalConduit conduit;
 
         public SynchronousConduit(LocalConduit conduit) {
@@ -88,42 +145,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)) {
-                                if (exchange == null) {
-                                    ex = localDestinationFactory.getExecutor(bus);
-                                } else {
-                                    ex = localDestinationFactory.getExecutor(exchange.getBus());
-                                }
-                                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/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java?rev=1532865&r1=1532864&r2=1532865&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
(original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLocalTransportTest.java
Wed Oct 16 19:14:50 2013
@@ -97,7 +97,6 @@ public class JAXRSLocalTransportTest ext
     }
     
     @Test
-    @Ignore
     public void testProxyEmtpyResponse() throws Exception {
         BookStore localProxy = JAXRSClientFactory.create("local://books", BookStore.class);
         assertNull(localProxy.getEmptyBook());



Mime
View raw message