From d9100917d10cb7e5d0b51c33aae85167ca5f0266 Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Thu, 13 Feb 2025 15:18:51 +0000 Subject: [PATCH] Refine onError handling WebAsyncManager In addition to the wrapping of errors recognized as client disconnected errors with AsyncRequestNotUsableException, we now wrap any IOException in the onError callback. The Servlet container would only be aware of such an exception if it relates to the response. Closes gh-33832 --- .../web/context/request/async/WebAsyncManager.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncManager.java b/spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncManager.java index 45aeecba96..2997bf8cb7 100644 --- a/spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncManager.java +++ b/spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncManager.java @@ -16,6 +16,7 @@ package org.springframework.web.context.request.async; +import java.io.IOException; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; @@ -34,7 +35,6 @@ import org.springframework.core.task.SimpleAsyncTaskExecutor; import org.springframework.util.Assert; import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.async.DeferredResult.DeferredResultHandler; -import org.springframework.web.util.DisconnectedClientHelper; /** * The central class for managing asynchronous request processing, mainly intended @@ -343,7 +343,7 @@ public final class WebAsyncManager { if (logger.isDebugEnabled()) { logger.debug("Servlet container error notification for " + formatUri(this.asyncWebRequest) + ": " + ex); } - if (DisconnectedClientHelper.isClientDisconnectedException(ex)) { + if (ex instanceof IOException) { ex = new AsyncRequestNotUsableException( "Servlet container error notification for disconnected client", ex); } @@ -439,7 +439,7 @@ public final class WebAsyncManager { if (logger.isDebugEnabled()) { logger.debug("Servlet container error notification for " + formatUri(this.asyncWebRequest)); } - if (DisconnectedClientHelper.isClientDisconnectedException(ex)) { + if (ex instanceof IOException) { ex = new AsyncRequestNotUsableException( "Servlet container error notification for disconnected client", ex); }