|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2023 the original author or authors. |
| 2 | + * Copyright 2002-2024 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
33 | 33 | import org.springframework.util.Assert;
|
34 | 34 | import org.springframework.web.context.request.RequestAttributes;
|
35 | 35 | import org.springframework.web.context.request.async.DeferredResult.DeferredResultHandler;
|
| 36 | +import org.springframework.web.util.DisconnectedClientHelper; |
36 | 37 |
|
37 | 38 | /**
|
38 | 39 | * The central class for managing asynchronous request processing, mainly intended
|
@@ -66,6 +67,16 @@ public final class WebAsyncManager {
|
66 | 67 |
|
67 | 68 | private static final Log logger = LogFactory.getLog(WebAsyncManager.class);
|
68 | 69 |
|
| 70 | + /** |
| 71 | + * Log category to use for network failure after a client has gone away. |
| 72 | + * @see DisconnectedClientHelper |
| 73 | + */ |
| 74 | + private static final String DISCONNECTED_CLIENT_LOG_CATEGORY = |
| 75 | + "org.springframework.web.server.DisconnectedClient"; |
| 76 | + |
| 77 | + private static final DisconnectedClientHelper disconnectedClientHelper = |
| 78 | + new DisconnectedClientHelper(DISCONNECTED_CLIENT_LOG_CATEGORY); |
| 79 | + |
69 | 80 | private static final CallableProcessingInterceptor timeoutCallableInterceptor =
|
70 | 81 | new TimeoutCallableProcessingInterceptor();
|
71 | 82 |
|
@@ -370,9 +381,13 @@ private void setConcurrentResultAndDispatch(@Nullable Object result) {
|
370 | 381 | return;
|
371 | 382 | }
|
372 | 383 |
|
| 384 | + if (result instanceof Exception ex && disconnectedClientHelper.checkAndLogClientDisconnectedException(ex)) { |
| 385 | + return; |
| 386 | + } |
| 387 | + |
373 | 388 | if (logger.isDebugEnabled()) {
|
374 |
| - boolean isError = result instanceof Throwable; |
375 |
| - logger.debug("Async " + (isError ? "error" : "result set") + ", dispatch to " + formatRequestUri()); |
| 389 | + logger.debug("Async " + (this.errorHandlingInProgress ? "error" : "result set") + |
| 390 | + ", dispatch to " + formatRequestUri()); |
376 | 391 | }
|
377 | 392 | this.asyncWebRequest.dispatch();
|
378 | 393 | }
|
|
0 commit comments