提交 4edc7196 编写于 作者: R Rossen Stoyanchev

Refine disconnected client handling in WebFlux

If an error looks like a "disconnected client" but the response is not
yet committed then it can't be an I/O error from writing to the server
response. It is most likely as a result of a remote call as part of
request handling.

Not setting the response to 500 in this case results in a 200 response
status despite the error. Even if it was an I/O error from the server
response, setting the status won't impact a failed response.

Closes gh-23319
上级 8f684682
......@@ -268,6 +268,11 @@ public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHa
String logPrefix = exchange.getLogPrefix();
if (isDisconnectedClientError(ex)) {
// Request handling error (e.g. remote call), if we manage to set the status..
if (response.setStatusCode(HttpStatus.INTERNAL_SERVER_ERROR)) {
logger.error(logPrefix + "500 Server Error for " + formatRequest(request), ex);
return Mono.empty();
}
if (lostClientLogger.isTraceEnabled()) {
lostClientLogger.trace(logPrefix + "Client went away", ex);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册