cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1349022 - in /cxf/branches/2.6.x-fixes: api/src/main/java/org/apache/cxf/interceptor/ api/src/main/java/org/apache/cxf/io/ rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ rt/transports/http/src/main/java/org/apache/cxf/tr...
Date Mon, 11 Jun 2012 21:25:04 GMT
Author: dkulp
Date: Mon Jun 11 21:25:03 2012
New Revision: 1349022

URL: http://svn.apache.org/viewvc?rev=1349022&view=rev
Log:
Merged revisions 1349016 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1349016 | dkulp | 2012-06-11 17:16:43 -0400 (Mon, 11 Jun 2012) | 2 lines

  [CXF-4371] Only block the flush for StaxOut based writing.

........

Modified:
    cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/interceptor/StaxOutInterceptor.java
    cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/io/AbstractWrappedOutputStream.java
    cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementWriter.java
    cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
    cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
    cxf/branches/2.6.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisClientServerTest.java

Modified: cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/interceptor/StaxOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/interceptor/StaxOutInterceptor.java?rev=1349022&r1=1349021&r2=1349022&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/interceptor/StaxOutInterceptor.java
(original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/interceptor/StaxOutInterceptor.java
Mon Jun 11 21:25:03 2012
@@ -31,6 +31,7 @@ import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.i18n.BundleUtils;
+import org.apache.cxf.io.AbstractWrappedOutputStream;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.message.MessageUtils;
@@ -75,6 +76,7 @@ public class StaxOutInterceptor extends 
             XMLOutputFactory factory = getXMLOutputFactory(message);
             if (factory == null) {
                 if (writer == null) {
+                    os = setupOutputStream(message, os);
                     xwriter = StaxUtils.createXMLStreamWriter(os, encoding);
                 } else {
                     xwriter = StaxUtils.createXMLStreamWriter(writer);
@@ -82,6 +84,7 @@ public class StaxOutInterceptor extends 
             } else {
                 synchronized (factory) {
                     if (writer == null) {
+                        os = setupOutputStream(message, os);
                         xwriter = factory.createXMLStreamWriter(os, encoding);
                     } else {
                         xwriter = factory.createXMLStreamWriter(writer);
@@ -103,6 +106,14 @@ public class StaxOutInterceptor extends 
         // Add a final interceptor to write end elements
         message.getInterceptorChain().add(ENDING);
     }
+    private OutputStream setupOutputStream(Message message, OutputStream os) {
+        if (!(os instanceof AbstractWrappedOutputStream)) {
+            os = new AbstractWrappedOutputStream(os) { };
+        }
+        ((AbstractWrappedOutputStream)os).allowFlush(false);
+        return os;
+    }
+
     @Override
     public void handleFault(Message message) {
         super.handleFault(message);

Modified: cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/io/AbstractWrappedOutputStream.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/io/AbstractWrappedOutputStream.java?rev=1349022&r1=1349021&r2=1349022&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/io/AbstractWrappedOutputStream.java
(original)
+++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/io/AbstractWrappedOutputStream.java
Mon Jun 11 21:25:03 2012
@@ -31,10 +31,15 @@ public abstract class AbstractWrappedOut
 
     protected OutputStream wrappedStream;
     protected boolean written;
+    protected boolean allowFlush = true;
     
     protected AbstractWrappedOutputStream() {
         super();
     }
+    protected AbstractWrappedOutputStream(OutputStream os) {
+        super();
+        wrappedStream = os;
+    }
 
     @Override
     public void write(byte[] b, int off, int len) throws IOException {
@@ -75,8 +80,12 @@ public abstract class AbstractWrappedOut
 
     @Override
     public void flush() throws IOException {
-        if (written && wrappedStream != null) {
+        if (written && wrappedStream != null && allowFlush) {
             wrappedStream.flush();
         }
     }
+    
+    public void allowFlush(boolean b) {
+        this.allowFlush = b;
+    }
 }

Modified: cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementWriter.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementWriter.java?rev=1349022&r1=1349021&r2=1349022&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementWriter.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementWriter.java
Mon Jun 11 21:25:03 2012
@@ -168,7 +168,6 @@ public class ElementWriter extends Abstr
     public void close() {
         try {
             writer.writeEndElement();
-            writer.flush();
         } catch (XMLStreamException e) {
             throw new DatabindingException("Error writing document.", e);
         }

Modified: cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java?rev=1349022&r1=1349021&r2=1349022&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
Mon Jun 11 21:25:03 2012
@@ -699,11 +699,6 @@ public abstract class AbstractHTTPDestin
             }
             */
         }
-        
-        public void flush() throws IOException {
-            //ignore until we close 
-            // or we'll force chunking and cause all kinds of network packets
-        }
     }
 
     protected boolean contextMatchOnExact() {

Modified: cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java?rev=1349022&r1=1349021&r2=1349022&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/HTTPConduit.java
Mon Jun 11 21:25:03 2012
@@ -1408,12 +1408,6 @@ public class HTTPConduit 
             
         }
 
-        public void flush() throws IOException {
-            if (!chunking) {
-                super.flush();
-            }
-        }
-        
         /**
          * Perform any actions required on stream closure (handle response etc.)
          */

Modified: cxf/branches/2.6.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisClientServerTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisClientServerTest.java?rev=1349022&r1=1349021&r2=1349022&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisClientServerTest.java
(original)
+++ cxf/branches/2.6.x-fixes/systests/databinding/src/test/java/org/apache/cxf/systest/aegis/AegisClientServerTest.java
Mon Jun 11 21:25:03 2012
@@ -53,9 +53,9 @@ public class AegisClientServerTest exten
     
     @BeforeClass
     public static void startServers() throws Exception {
-        assertTrue("server did not launch correctly", launchServer(AegisServer.class));
+        assertTrue("server did not launch correctly", launchServer(AegisServer.class, true));
     }
-    
+
     @Test
     public void testAegisClient() throws Exception {
         AegisDatabinding aegisBinding = new AegisDatabinding();



Mime
View raw message