Author: markt
Date: Wed Oct 29 12:29:41 2014
New Revision: 1635112
URL: http://svn.apache.org/r1635112
Log:
Don't try and carry on if there is an ISE when trying to use non-blocking IO.
Treat it as the error it is.
Found this while debugging the test case in BZ 57157.
Modified:
tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
tomcat/trunk/webapps/docs/changelog.xml
Modified:
tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java?rev=1635112&r1=1635111&r2=1635112&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java
(original)
+++ tomcat/trunk/java/org/apache/coyote/http11/AbstractHttp11Processor.java Wed
Oct 29 12:29:41 2014
@@ -1639,24 +1639,23 @@ public abstract class AbstractHttp11Proc
if (status == SocketStatus.OPEN_WRITE) {
try {
asyncStateMachine.asyncOperation();
- try {
- if (outputBuffer.hasDataToWrite()) {
- if (outputBuffer.flushBuffer(false)) {
- // There is data to write but go via Response to
- // maintain a consistent view of non-blocking state
- response.checkRegisterForWrite(true);
- return SocketState.LONG;
- }
- }
- } catch (IOException x) {
- if (getLog().isDebugEnabled()) {
- getLog().debug("Unable to write async data.",x);
+
+ if (outputBuffer.hasDataToWrite()) {
+ if (outputBuffer.flushBuffer(false)) {
+ // There is data to write but go via Response to
+ // maintain a consistent view of non-blocking state
+ response.checkRegisterForWrite(true);
+ return SocketState.LONG;
}
- status = SocketStatus.ASYNC_WRITE_ERROR;
- request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, x);
}
- } catch (IllegalStateException x) {
- registerForEvent(false, true);
+ } catch (IOException | IllegalStateException x) {
+ // IOE - Problem writing to socket
+ // ISE - Request/Response not in correct state for async write
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("Unable to write async data.",x);
+ }
+ status = SocketStatus.ASYNC_WRITE_ERROR;
+ request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, x);
}
} else if (status == SocketStatus.OPEN_READ &&
request.getReadListener() != null) {
@@ -1665,7 +1664,12 @@ public abstract class AbstractHttp11Proc
asyncStateMachine.asyncOperation();
}
} catch (IllegalStateException x) {
- registerForEvent(true, false);
+ // ISE - Request/Response not in correct state for async read
+ if (getLog().isDebugEnabled()) {
+ getLog().debug("Unable to read async data.",x);
+ }
+ status = SocketStatus.ASYNC_READ_ERROR;
+ request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, x);
}
}
Modified: tomcat/trunk/webapps/docs/changelog.xml
URL:
http://svn.apache.org/viewvc/tomcat/trunk/webapps/docs/changelog.xml?rev=1635112&r1=1635111&r2=1635112&view=diff
==============================================================================
--- tomcat/trunk/webapps/docs/changelog.xml (original)
+++ tomcat/trunk/webapps/docs/changelog.xml Wed Oct 29 12:29:41 2014
@@ -205,6 +205,10 @@
Do not increase remaining counter at end of stream in
IdentityInputFilter. (kkolinko)
</fix>
+ <fix>
+ Trigger an error if an invalid attempt is made to use non-blocking IO.
+ (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Jasper">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]