From 1e6f68ac3b9f97414f61e73cd23d79091b50d1d5 Mon Sep 17 00:00:00 2001 From: gregw Date: Thu, 30 Nov 2023 09:12:16 +1100 Subject: [PATCH] Call ServletChannelState.asyncFailure from error listener. Fix #10933 --- .../eclipse/jetty/ee10/servlet/ServletChannelState.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletChannelState.java b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletChannelState.java index b0e6996a2550..9f538b7f5b62 100644 --- a/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletChannelState.java +++ b/jetty-ee10/jetty-ee10-servlet/src/main/java/org/eclipse/jetty/ee10/servlet/ServletChannelState.java @@ -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) { @@ -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; @@ -1078,7 +1084,7 @@ protected void recycle() try (AutoLock ignored = lock()) { if (LOG.isDebugEnabled()) - LOG.debug("recycle {}", toStringLocked()); + LOG.debug("recycle {}", toStringLocked()) switch (_state) { @@ -1099,6 +1105,7 @@ protected void recycle() _asyncWritePossible = false; _timeoutMs = DEFAULT_TIMEOUT; _event = null; + _failureListener = false; } }