Skip to content

Commit

Permalink
Simplify. ISE should be impossible. There is only one container threa…
Browse files Browse the repository at this point in the history
…d at a time. To get this far thread must be in STARTED stated which means no ISE will be thrown.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1705926 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
markt-asf committed Sep 29, 2015
1 parent a902197 commit 15790b8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 53 deletions.
38 changes: 15 additions & 23 deletions java/org/apache/coyote/ajp/AjpProcessor.java
Expand Up @@ -621,35 +621,27 @@ public final void action(ActionCode actionCode, Object param) {
public SocketState dispatch(SocketStatus status) {

if (status == SocketStatus.OPEN_WRITE && response.getWriteListener() != null) {
asyncStateMachine.asyncOperation();
try {
asyncStateMachine.asyncOperation();
try {
if (hasDataToWrite()) {
socketWrapper.flush(false);
if (hasDataToWrite()) {
socketWrapper.flush(false);
if (hasDataToWrite()) {
// There is data to write but go via Response to
// maintain a consistent view of non-blocking state
response.checkRegisterForWrite();
return SocketState.LONG;
}
// There is data to write but go via Response to
// maintain a consistent view of non-blocking state
response.checkRegisterForWrite();
return SocketState.LONG;
}
} catch (IOException x) {
if (getLog().isDebugEnabled()) {
getLog().debug("Unable to write async data.",x);
}
status = SocketStatus.ASYNC_WRITE_ERROR;
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, x);
}
} catch (IllegalStateException x) {
socketWrapper.registerWriteInterest();
} catch (IOException ioe) {
if (getLog().isDebugEnabled()) {
getLog().debug("Unable to write async data.", ioe);
}
status = SocketStatus.ASYNC_WRITE_ERROR;
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, ioe);
}
} else if (status == SocketStatus.OPEN_READ && request.getReadListener() != null) {
try {
if (available()) {
asyncStateMachine.asyncOperation();
}
} catch (IllegalStateException x) {
socketWrapper.registerReadInterest();
if (available()) {
asyncStateMachine.asyncOperation();
}
}

Expand Down
19 changes: 4 additions & 15 deletions java/org/apache/coyote/http11/Http11Processor.java
Expand Up @@ -1714,26 +1714,15 @@ public SocketState dispatch(SocketStatus status) {
return SocketState.LONG;
}
}
} catch (IOException | IllegalStateException x) {
// IOE - Problem writing to socket
// ISE - Request/Response not in correct state for async write
} catch (IOException ioe) {
if (log.isDebugEnabled()) {
log.debug("Unable to write async data.",x);
log.debug("Unable to write async data.", ioe);
}
status = SocketStatus.ASYNC_WRITE_ERROR;
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, x);
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, ioe);
}
} else if (status == SocketStatus.OPEN_READ && request.getReadListener() != null) {
try {
asyncStateMachine.asyncOperation();
} catch (IllegalStateException x) {
// ISE - Request/Response not in correct state for async read
if (log.isDebugEnabled()) {
log.debug("Unable to read async data.",x);
}
status = SocketStatus.ASYNC_READ_ERROR;
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, x);
}
asyncStateMachine.asyncOperation();
}

RequestInfo rp = request.getRequestProcessor();
Expand Down
19 changes: 4 additions & 15 deletions java/org/apache/coyote/http2/StreamProcessor.java
Expand Up @@ -424,26 +424,15 @@ public SocketState dispatch(SocketStatus status) {
}
return SocketState.LONG;
}
} catch (IOException | IllegalStateException x) {
// IOE - Problem writing to socket
// ISE - Request/Response not in correct state for async write
} catch (IOException ioe) {
if (log.isDebugEnabled()) {
log.debug("Unable to write async data.",x);
log.debug("Unable to write async data.", ioe);
}
status = SocketStatus.ASYNC_WRITE_ERROR;
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, x);
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, ioe);
}
} else if (status == SocketStatus.OPEN_READ && request.getReadListener() != null) {
try {
asyncStateMachine.asyncOperation();
} catch (IllegalStateException x) {
// ISE - Request/Response not in correct state for async read
if (log.isDebugEnabled()) {
log.debug("Unable to read async data.",x);
}
status = SocketStatus.ASYNC_READ_ERROR;
request.setAttribute(RequestDispatcher.ERROR_EXCEPTION, x);
}
asyncStateMachine.asyncOperation();
}

RequestInfo rp = request.getRequestProcessor();
Expand Down

0 comments on commit 15790b8

Please sign in to comment.