Pull up finish() so output() is used consistently to wrote closing message
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 23 Aug 2011 12:19:20 +0000 (12:19 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Tue, 23 Aug 2011 12:19:20 +0000 (12:19 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1160652 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/coyote/ajp/AbstractAjpProcessor.java
java/org/apache/coyote/ajp/AjpAprProcessor.java
java/org/apache/coyote/ajp/AjpNioProcessor.java
java/org/apache/coyote/ajp/AjpProcessor.java

index 0acc719..9ed4df0 100644 (file)
@@ -537,7 +537,6 @@ public abstract class AbstractAjpProcessor<S> extends AbstractProcessor<S> {
 
     // Methods called by action()
     protected abstract void actionInternal(ActionCode actionCode, Object param);
-    protected abstract void finish() throws IOException;
 
     // Methods called by prepareResponse()
     protected abstract void output(byte[] src, int offset, int length)
@@ -939,6 +938,35 @@ public abstract class AbstractAjpProcessor<S> extends AbstractProcessor<S> {
     }
 
 
+    /**
+     * Finish AJP response.
+     */
+    protected void finish() throws IOException {
+
+        if (!response.isCommitted()) {
+            // Validate and write response headers
+            try {
+                prepareResponse();
+            } catch (IOException e) {
+                // Set error flag
+                error = true;
+            }
+        }
+
+        if (finished)
+            return;
+
+        finished = true;
+
+        // Add the end message
+        if (error) {
+            output(endAndCloseMessageArray, 0, endAndCloseMessageArray.length);
+        } else {
+            output(endMessageArray, 0, endMessageArray.length);
+        }
+    }
+
+
     // ------------------------------------- InputStreamInputBuffer Inner Class
 
 
index 70c6fb8..7db138a 100644 (file)
@@ -282,43 +282,6 @@ public class AjpAprProcessor extends AbstractAjpProcessor<Long> {
 
 
     /**
-     * Finish AJP response.
-     */
-    @Override
-    protected void finish() throws IOException {
-
-        if (!response.isCommitted()) {
-            // Validate and write response headers
-            try {
-                prepareResponse();
-            } catch (IOException e) {
-                // Set error flag
-                error = true;
-            }
-        }
-
-        if (finished)
-            return;
-
-        finished = true;
-
-        // Add the end message
-        byte[] messageArray;
-        if (error) {
-            messageArray = endAndCloseMessageArray;
-        } else {
-            messageArray = endMessageArray;
-        }
-        if (outputBuffer.position() + messageArray.length > outputBuffer.capacity()) {
-            flush(false);
-        }
-        outputBuffer.put(messageArray);
-        flush(false);
-
-    }
-
-
-    /**
      * Read at least the specified amount of bytes, and place them
      * in the input buffer.
      */
index 48f1d9b..de98eb6 100644 (file)
@@ -292,37 +292,6 @@ public class AjpNioProcessor extends AbstractAjpProcessor<NioChannel> {
         writeBuffer.clear();
     }
 
-    /**
-     * Finish AJP response.
-     */
-    @Override
-    protected void finish() throws IOException {
-
-        if (!response.isCommitted()) {
-            // Validate and write response headers
-            try {
-                prepareResponse();
-            } catch (IOException e) {
-                // Set error flag
-                error = true;
-            }
-        }
-
-        if (finished)
-            return;
-
-        finished = true;
-
-        // Add the end message
-        byte[] messageArray;
-        if (error) {
-            messageArray = endAndCloseMessageArray;
-        } else {
-            messageArray = endMessageArray;
-        }
-        output(messageArray, 0, messageArray.length);
-    }
-
 
     /**
      * Read the specified amount of bytes, and place them in the input buffer.
index d47b1eb..3c69b83 100644 (file)
@@ -287,32 +287,6 @@ public class AjpProcessor extends AbstractAjpProcessor<Socket> {
         output.write(src, offset, length);
     }
 
-    /**
-     * Finish AJP response.
-     */
-    @Override
-    protected void finish() throws IOException {
-
-        if (!response.isCommitted()) {
-            // Validate and write response headers
-            try {
-                prepareResponse();
-            } catch (IOException e) {
-                // Set error flag
-                error = true;
-            }
-        }
-
-        if (finished)
-            return;
-
-        finished = true;
-
-        // Add the end message
-        output.write(error ? endAndCloseMessageArray : endMessageArray);
-
-    }
-
 
     /**
      * Read at least the specified amount of bytes, and place them