Skip to content

Commit

Permalink
Call ServletChannelState.asyncFailure from error listener. Fix #10933
Browse files Browse the repository at this point in the history
  • Loading branch information
gregw committed Nov 29, 2023
1 parent 3f2c30a commit 1e6f68a
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public enum Action
private long _timeoutMs = DEFAULT_TIMEOUT;
private AsyncContextEvent _event;
private Thread _onTimeoutThread;
private boolean _failureListener;

protected ServletChannelState(ServletChannel servletChannel)
{
Expand Down Expand Up @@ -511,6 +512,11 @@ public void startAsync(AsyncContextEvent event)
if (_state != State.HANDLING || (_requestState != RequestState.BLOCKING && _requestState != RequestState.ERRORING))
throw new IllegalStateException(this.getStatusStringLocked());

if (!_failureListener)
{
_failureListener = true;
_servletChannel.getRequest().addFailureListener(this::asyncError);
}
_requestState = RequestState.ASYNC;
_event = event;
lastAsyncListeners = _asyncListeners;
Expand Down Expand Up @@ -1078,7 +1084,7 @@ protected void recycle()
try (AutoLock ignored = lock())
{
if (LOG.isDebugEnabled())
LOG.debug("recycle {}", toStringLocked());
LOG.debug("recycle {}", toStringLocked())

switch (_state)
{
Expand All @@ -1099,6 +1105,7 @@ protected void recycle()
_asyncWritePossible = false;
_timeoutMs = DEFAULT_TIMEOUT;
_event = null;
_failureListener = false;
}
}

Expand Down

0 comments on commit 1e6f68a

Please sign in to comment.