Author: markt
Date: Tue Aug 23 12:49:36 2011
New Revision: 1160666
URL: http://svn.apache.org/viewvc?rev=1160666&view=rev
Log:
More re-factoring to reduce duplication. Pull up flush() and finish()
Modified:
tomcat/tc7.0.x/trunk/ (props changed)
tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java
tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java
tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java
tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java
Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Aug 23 12:49:36 2011
@@ -1 +1 @@
-/tomcat/trunk:1156171,1156276,1156304,1156530,1156602,1157015,1157018,1157151,1157198,1157204,1157810,1157832,1157834,1157847,1157908,1157939,1158155,1158160,1158176,1158195,1158198-1158199,1158227,1158331,1158334-1158335,1160347,1160592,1160611,1160619,1160626
+/tomcat/trunk:1156171,1156276,1156304,1156530,1156602,1157015,1157018,1157151,1157198,1157204,1157810,1157832,1157834,1157847,1157908,1157939,1158155,1158160,1158176,1158195,1158198-1158199,1158227,1158331,1158334-1158335,1160347,1160592,1160611,1160619,1160626,1160639,1160652
Modified:
tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java?rev=1160666&r1=1160665&r2=1160666&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AbstractAjpProcessor.java
Tue Aug 23 12:49:36 2011
@@ -537,8 +537,6 @@ public abstract class AbstractAjpProcess
// Methods called by action()
protected abstract void actionInternal(ActionCode actionCode, Object
param);
- protected abstract void flush(boolean tbd) throws IOException;
- protected abstract void finish() throws IOException;
// Methods called by prepareResponse()
protected abstract void output(byte[] src, int offset, int length)
@@ -557,6 +555,17 @@ public abstract class AbstractAjpProcess
/**
+ * Callback to write data from the buffer.
+ */
+ protected void flush(boolean explicit) throws IOException {
+ if (explicit && !finished) {
+ // Send the flush message
+ output(flushMessageArray, 0, flushMessageArray.length);
+ }
+ }
+
+
+ /**
* After reading the request headers, we have to setup the request filters.
*/
protected void prepareRequest() {
@@ -929,6 +938,35 @@ public abstract class AbstractAjpProcess
}
+ /**
+ * 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
Modified: tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java?rev=1160666&r1=1160665&r2=1160666&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpAprProcessor.java Tue
Aug 23 12:49:36 2011
@@ -269,43 +269,15 @@ public class AjpAprProcessor extends Abs
protected void output(byte[] src, int offset, int length)
throws IOException {
outputBuffer.put(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;
+
+ long socketRef = socket.getSocket().longValue();
+
+ if (outputBuffer.position() > 0) {
+ if ((socketRef != 0) && Socket.sendbb(socketRef, 0,
outputBuffer.position()) < 0) {
+ throw new IOException(sm.getString("ajpprocessor.failedsend"));
}
+ outputBuffer.clear();
}
-
- 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);
-
}
@@ -497,28 +469,4 @@ public class AjpAprProcessor extends Abs
outputBuffer.clear();
}
-
-
- /**
- * Callback to write data from the buffer.
- */
- @Override
- protected void flush(boolean explicit) throws IOException {
-
- long socketRef = socket.getSocket().longValue();
-
- if (outputBuffer.position() > 0) {
- if ((socketRef != 0) && Socket.sendbb(socketRef, 0,
outputBuffer.position()) < 0) {
- throw new IOException(sm.getString("ajpprocessor.failedsend"));
- }
- outputBuffer.clear();
- }
- // Send explicit flush message
- if (explicit && !finished && (socketRef != 0)) {
- if (Socket.send(socketRef, flushMessageArray, 0,
- flushMessageArray.length) < 0) {
- throw new
IOException(sm.getString("ajpprocessor.failedflush"));
- }
- }
- }
}
Modified: tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java?rev=1160666&r1=1160665&r2=1160666&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java
(original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpNioProcessor.java Tue
Aug 23 12:49:36 2011
@@ -292,37 +292,6 @@ public class AjpNioProcessor extends Abs
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.
@@ -486,14 +455,4 @@ public class AjpNioProcessor extends Abs
}
- /**
- * Callback to write data from the buffer.
- */
- @Override
- protected void flush(boolean explicit) throws IOException {
- if (explicit && !finished) {
- // Send the flush message
- output(flushMessageArray, 0, flushMessageArray.length);
- }
- }
}
Modified: tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java?rev=1160666&r1=1160665&r2=1160666&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java (original)
+++ tomcat/tc7.0.x/trunk/java/org/apache/coyote/ajp/AjpProcessor.java Tue Aug
23 12:49:36 2011
@@ -287,32 +287,6 @@ public class AjpProcessor extends Abstra
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
@@ -433,16 +407,4 @@ public class AjpProcessor extends Abstra
return true;
}
}
-
-
- /**
- * Callback to write data from the buffer.
- */
- @Override
- protected void flush(boolean explicit) throws IOException {
- if (explicit && !finished) {
- // Send the flush message
- output.write(flushMessageArray);
- }
- }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]