Merge pull request #16406 from izeye

* pr/16406:
  Check for Reactor Netty disconnected client errors
This commit is contained in:
Stephane Nicoll 2019-04-03 11:45:58 +02:00
commit 0b828db603
1 changed files with 10 additions and 5 deletions

View File

@ -64,7 +64,8 @@ public abstract class AbstractErrorWebExceptionHandler
* Currently duplicated from Spring WebFlux HttpWebHandlerAdapter. * Currently duplicated from Spring WebFlux HttpWebHandlerAdapter.
*/ */
private static final Set<String> DISCONNECTED_CLIENT_EXCEPTIONS = new HashSet<>( private static final Set<String> DISCONNECTED_CLIENT_EXCEPTIONS = new HashSet<>(
Arrays.asList("ClientAbortException", "EOFException", "EofException")); Arrays.asList("AbortedException", "ClientAbortException", "EOFException",
"EofException"));
private static final Log logger = HttpLogging private static final Log logger = HttpLogging
.forLogName(AbstractErrorWebExceptionHandler.class); .forLogName(AbstractErrorWebExceptionHandler.class);
@ -268,10 +269,14 @@ public abstract class AbstractErrorWebExceptionHandler
private boolean isDisconnectedClientError(Throwable ex) { private boolean isDisconnectedClientError(Throwable ex) {
String message = NestedExceptionUtils.getMostSpecificCause(ex).getMessage(); String message = NestedExceptionUtils.getMostSpecificCause(ex).getMessage();
message = (message != null) ? message.toLowerCase() : ""; if (message != null) {
String className = ex.getClass().getSimpleName(); String text = message.toLowerCase();
return (message.contains("broken pipe") if (text.contains("broken pipe")
|| DISCONNECTED_CLIENT_EXCEPTIONS.contains(className)); || text.contains("connection reset by peer")) {
return true;
}
}
return DISCONNECTED_CLIENT_EXCEPTIONS.contains(ex.getClass().getSimpleName());
} }
private void logError(ServerRequest request, ServerResponse response, private void logError(ServerRequest request, ServerResponse response,