clearNonBlockingListeners(); boolean triggerDispatch = false; if (state == AsyncState.STARTING || state == AsyncState.MUST_ERROR) { // Processing is on a container thread so no need to transfer // processing to a new container thread
updateState(AsyncState.MUST_COMPLETE);
} elseif (state == AsyncState.STARTED) {
updateState(AsyncState.COMPLETING); // A dispatch to a container thread is always required. // If on a non-container thread, need to get back onto a container // thread to complete the processing. // If on a container thread the current request/response are not the // request/response associated with the AsyncContext so need a new // container thread to process the different request/response.
triggerDispatch = true;
} elseif (state == AsyncState.READ_WRITE_OP || state == AsyncState.TIMING_OUT || state == AsyncState.ERROR) { // Read/write operations can happen on or off a container thread but // while in this state the call to listener that triggers the // read/write will be in progress on a container thread. // Processing of timeouts and errors can happen on or off a // container thread (on is much more likely) but while in this state // the call that triggers the timeout will be in progress on a // container thread. // The socket will be added to the poller when the container thread // exits the AbstractConnectionHandler.process() method so don't do // a dispatch here which would add it to the poller a second time.
updateState(AsyncState.COMPLETING);
} else { thrownew IllegalStateException(
sm.getString("asyncStateMachine.invalidAsyncState", "asyncComplete()", state));
} return triggerDispatch;
}
synchronizedboolean asyncTimeout() { if (state == AsyncState.STARTED) {
updateState(AsyncState.TIMING_OUT); returntrue;
} elseif (state == AsyncState.COMPLETING || state == AsyncState.DISPATCHING ||
state == AsyncState.DISPATCHED) { // NOOP - App called complete() or dispatch() between the the // timeout firing and execution reaching this point returnfalse;
} else { thrownew IllegalStateException(
sm.getString("asyncStateMachine.invalidAsyncState", "asyncTimeout()", state));
}
}
clearNonBlockingListeners(); boolean triggerDispatch = false; if (state == AsyncState.STARTING || state == AsyncState.MUST_ERROR) { // Processing is on a container thread so no need to transfer // processing to a new container thread
updateState(AsyncState.MUST_DISPATCH);
} elseif (state == AsyncState.STARTED) {
updateState(AsyncState.DISPATCHING); // A dispatch to a container thread is always required. // If on a non-container thread, need to get back onto a container // thread to complete the processing. // If on a container thread the current request/response are not the // request/response associated with the AsyncContext so need a new // container thread to process the different request/response.
triggerDispatch = true;
} elseif (state == AsyncState.READ_WRITE_OP || state == AsyncState.TIMING_OUT || state == AsyncState.ERROR) { // Read/write operations can happen on or off a container thread but // while in this state the call to listener that triggers the // read/write will be in progress on a container thread. // Processing of timeouts and errors can happen on or off a // container thread (on is much more likely) but while in this state // the call that triggers the timeout will be in progress on a // container thread. // The socket will be added to the poller when the container thread // exits the AbstractConnectionHandler.process() method so don't do // a dispatch here which would add it to the poller a second time.
updateState(AsyncState.DISPATCHING);
} else { thrownew IllegalStateException(
sm.getString("asyncStateMachine.invalidAsyncState", "asyncDispatch()", state));
} return triggerDispatch;
}
if (log.isDebugEnabled()) {
log.debug(sm.getString("asyncStateMachine.asyncError.start"));
}
clearNonBlockingListeners(); if (state == AsyncState.STARTING) {
updateState(AsyncState.MUST_ERROR);
} else { if (hasProcessedError) { if (log.isDebugEnabled()) {
log.debug(sm.getString("asyncStateMachine.asyncError.skip"));
} returnfalse;
}
hasProcessedError = true; if (state == AsyncState.DISPATCHED) { // Async error handling has moved processing back into an async // state. Need to increment in progress count as it will decrement // when the async state is exited again.
asyncCtxt.incrementInProgressAsyncCount();
updateState(AsyncState.ERROR);
} else {
updateState(AsyncState.ERROR);
}
}
// Return true for non-container threads to trigger a dispatch return !containerThread;
}
synchronizedvoid asyncRun(Runnable runnable) { if (state == AsyncState.STARTING || state == AsyncState.STARTED || state == AsyncState.READ_WRITE_OP) { // Execute the runnable using a container thread from the // Connector's thread pool. Use a wrapper to prevent a memory leak
ClassLoader oldCL; Thread currentThread = Thread.currentThread(); if (Constants.IS_SECURITY_ENABLED) {
PrivilegedAction<ClassLoader> pa = new PrivilegedGetTccl(currentThread);
oldCL = AccessController.doPrivileged(pa);
} else {
oldCL = currentThread.getContextClassLoader();
} try { if (Constants.IS_SECURITY_ENABLED) {
PrivilegedAction<Void> pa = new PrivilegedSetTccl(currentThread, this.getClass().getClassLoader());
AccessController.doPrivileged(pa);
} else {
currentThread.setContextClassLoader(this.getClass().getClassLoader());
}
processor.execute(runnable);
} finally { if (Constants.IS_SECURITY_ENABLED) {
PrivilegedAction<Void> pa = new PrivilegedSetTccl(currentThread, oldCL);
AccessController.doPrivileged(pa);
} else {
currentThread.setContextClassLoader(oldCL);
}
}
} else { thrownew IllegalStateException(sm.getString("asyncStateMachine.invalidAsyncState", "asyncRun()", state));
}
}
synchronizedboolean isAvailable() { if (asyncCtxt == null) { // Async processing has probably been completed in another thread. // Trigger a timeout to make sure the Processor is cleaned up. returnfalse;
} return asyncCtxt.isAvailable();
}
synchronizedvoid recycle() { // Use lastAsyncStart to determine if this instance has been used since // it was last recycled. If it hasn't there is no need to recycle again // which saves the relatively expensive call to notifyAll() if (lastAsyncStart == 0) { return;
} // Ensure in case of error that any non-container threads that have been // paused are unpaused.
notifyAll();
asyncCtxt = null;
state = AsyncState.DISPATCHED;
lastAsyncStart = 0;
hasProcessedError = false;
}
privatesynchronizedvoid updateState(AsyncState newState) { if (log.isDebugEnabled()) {
log.debug(sm.getString("asyncStateMachine.stateChange", state, newState));
}
state = newState;
}
}
Messung V0.5 in Prozent
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.7Bemerkung:
(vorverarbeitet am 2026-09-28)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.