Browse Source

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
pull/34440/head
rstoyanchev 10 months ago
parent
commit
d9100917d1
  1. 6
      spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncManager.java

6
spring-web/src/main/java/org/springframework/web/context/request/async/WebAsyncManager.java

@ -16,6 +16,7 @@
package org.springframework.web.context.request.async; package org.springframework.web.context.request.async;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
@ -34,7 +35,6 @@ import org.springframework.core.task.SimpleAsyncTaskExecutor;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.async.DeferredResult.DeferredResultHandler; 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 * The central class for managing asynchronous request processing, mainly intended
@ -343,7 +343,7 @@ public final class WebAsyncManager {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("Servlet container error notification for " + formatUri(this.asyncWebRequest) + ": " + ex); logger.debug("Servlet container error notification for " + formatUri(this.asyncWebRequest) + ": " + ex);
} }
if (DisconnectedClientHelper.isClientDisconnectedException(ex)) { if (ex instanceof IOException) {
ex = new AsyncRequestNotUsableException( ex = new AsyncRequestNotUsableException(
"Servlet container error notification for disconnected client", ex); "Servlet container error notification for disconnected client", ex);
} }
@ -439,7 +439,7 @@ public final class WebAsyncManager {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("Servlet container error notification for " + formatUri(this.asyncWebRequest)); logger.debug("Servlet container error notification for " + formatUri(this.asyncWebRequest));
} }
if (DisconnectedClientHelper.isClientDisconnectedException(ex)) { if (ex instanceof IOException) {
ex = new AsyncRequestNotUsableException( ex = new AsyncRequestNotUsableException(
"Servlet container error notification for disconnected client", ex); "Servlet container error notification for disconnected client", ex);
} }

Loading…
Cancel
Save