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
This commit is contained in:
parent
8f6846827d
commit
4edc7196fb
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue