Author: veithen
Date: Sun Feb  1 13:48:58 2009
New Revision: 739763

URL: http://svn.apache.org/viewvc?rev=739763&view=rev
Log:
Fixed an issue with end of stream handling.

Added:
    
webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/test/java/org/apache/ws/commons/tcpmon/core/filter/PipelineTest.java
   (with props)
Modified:
    
webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/filter/Pipeline.java

Modified: 
webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/filter/Pipeline.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/filter/Pipeline.java?rev=739763&r1=739762&r2=739763&view=diff
==============================================================================
--- 
webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/filter/Pipeline.java
 (original)
+++ 
webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/main/java/org/apache/ws/commons/tcpmon/core/filter/Pipeline.java
 Sun Feb  1 13:48:58 2009
@@ -64,7 +64,7 @@
         }
 
         public void invoke(byte[] buffer, int offset, int length, boolean eos, 
boolean preserve) {
-            while (length > 0) {
+            do {
                 if (inLength > 0) {
                     int c = fillBuffer(buffer, offset, length);
                     if (c == 0) {
@@ -79,7 +79,7 @@
                 }
                 this.lastBuffer = eos && length == 0;
                 filter.invoke(this);
-            }
+            } while (length > 0);
             flushSkip(eos);
             flushOutput(eos);
             if (inLength > 0) {
@@ -89,13 +89,18 @@
                 if (this.preserve) {
                     compactBuffer();
                 }
-            } else if (inBuffer != null) {
-                if (!this.preserve) {
-                    releaseBuffer(inBuffer);
+            } else {
+                if (eos && !eosSignalled) {
+                    invokeNext(inBuffer, inOffset, inLength, true, true);
+                }
+                if (inBuffer != null) {
+                    if (!this.preserve) {
+                        releaseBuffer(inBuffer);
+                    }
+                    inBuffer = null;
+                    inOffset = 0;
+                    inLength = 0;
                 }
-                inBuffer = null;
-                inOffset = 0;
-                inLength = 0;
             }
         }
         

Added: 
webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/test/java/org/apache/ws/commons/tcpmon/core/filter/PipelineTest.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/test/java/org/apache/ws/commons/tcpmon/core/filter/PipelineTest.java?rev=739763&view=auto
==============================================================================
--- 
webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/test/java/org/apache/ws/commons/tcpmon/core/filter/PipelineTest.java
 (added)
+++ 
webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/test/java/org/apache/ws/commons/tcpmon/core/filter/PipelineTest.java
 Sun Feb  1 13:48:58 2009
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ws.commons.tcpmon.core.filter;
+
+import java.io.OutputStream;
+
+import junit.framework.TestCase;
+
+public class PipelineTest extends TestCase {
+    private static class TestFilter implements StreamFilter {
+        private boolean eos;
+        
+        public void invoke(Stream stream) {
+            stream.skipAll();
+            eos = stream.isEndOfStream();
+        }
+
+        public boolean isEos() {
+            return eos;
+        }
+    }
+    
+    public void testEndOfStream() throws Exception {
+        Pipeline pipeline = new Pipeline();
+        TestFilter filter1 = new TestFilter();
+        pipeline.addFilter(filter1);
+        TestFilter filter2 = new TestFilter();
+        pipeline.addFilter(filter2);
+        OutputStream out = pipeline.getOutputStream();
+        out.write(new byte[10]);
+        out.close();
+        assertTrue(filter1.isEos());
+        assertTrue(filter2.isEos());
+    }
+}

Propchange: 
webservices/commons/trunk/modules/tcpmon/modules/tcpmon-core/src/test/java/org/apache/ws/commons/tcpmon/core/filter/PipelineTest.java
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to