Author: remy.maucherat(a)jboss.com
Date: 2008-03-31 07:02:10 -0400 (Mon, 31 Mar 2008)
New Revision: 567
Modified:
trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
trunk/java/org/apache/catalina/connector/InputBuffer.java
trunk/java/org/apache/catalina/connector/Request.java
Log:
- Add a separate EOF flag (since close checks are to be added, and throwing an IOE on
reads when the EOF has been
reached is not ok).
Modified: trunk/java/org/apache/catalina/connector/CoyoteAdapter.java
===================================================================
--- trunk/java/org/apache/catalina/connector/CoyoteAdapter.java 2008-03-31 10:09:38 UTC
(rev 566)
+++ trunk/java/org/apache/catalina/connector/CoyoteAdapter.java 2008-03-31 11:02:10 UTC
(rev 567)
@@ -241,13 +241,13 @@
error = true;
connector.getContainer().getPipeline().getFirst().event(request,
response, request.getEvent());
}
- if (!error && !eof && (status == SocketStatus.OPEN_READ)
&& request.isClosed()) {
+ if (!error && !eof && (status == SocketStatus.OPEN_READ)
&& request.isEof()) {
// Send an EOF event
request.getEvent().setType(CometEvent.EventType.EOF);
eof = true;
connector.getContainer().getPipeline().getFirst().event(request,
response, request.getEvent());
}
- if (!error && request.isClosed()) {
+ if (!error && request.isEof()) {
request.suspend();
}
if (error || close) {
Modified: trunk/java/org/apache/catalina/connector/InputBuffer.java
===================================================================
--- trunk/java/org/apache/catalina/connector/InputBuffer.java 2008-03-31 10:09:38 UTC (rev
566)
+++ trunk/java/org/apache/catalina/connector/InputBuffer.java 2008-03-31 11:02:10 UTC (rev
567)
@@ -86,6 +86,12 @@
/**
+ * Flag which indicates if the end of stream has been reached.
+ */
+ private boolean eof = false;
+
+
+ /**
* Encoding to use.
*/
private String enc;
@@ -212,6 +218,7 @@
markPos = -1;
bb.recycle();
closed = false;
+ eof = false;
if (conv != null) {
conv.recycle();
@@ -250,6 +257,14 @@
}
+ /**
+ * Returns if the eof has been reached.
+ */
+ public boolean isEof() {
+ return eof;
+ }
+
+
public int available() {
int available = 0;
if (state == BYTE_STATE) {
@@ -294,7 +309,7 @@
public int realReadBytes(byte cbuf[], int off, int len)
throws IOException {
- if (closed)
+ if (eof)
return -1;
if (coyoteRequest == null)
return -1;
@@ -305,7 +320,7 @@
try {
int n = coyoteRequest.doRead(bb);
if (n < 0) {
- closed = true;
+ eof = true;
}
return n;
} catch (IOException e) {
Modified: trunk/java/org/apache/catalina/connector/Request.java
===================================================================
--- trunk/java/org/apache/catalina/connector/Request.java 2008-03-31 10:09:38 UTC (rev
566)
+++ trunk/java/org/apache/catalina/connector/Request.java 2008-03-31 11:02:10 UTC (rev
567)
@@ -473,11 +473,11 @@
/**
- * Read bytes into the low level buffer.
+ * Return true if the EOF has been reached.
*/
- public boolean isClosed()
+ public boolean isEof()
throws IOException {
- return (inputBuffer.isClosed());
+ return (inputBuffer.isEof());
}
Show replies by date