From 5f111098b1fae1d2c61334abd4bba0398269c9f8 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 20 Mar 2019 09:01:22 -0400 Subject: [PATCH] Check for Reactor Netty disconnected client errors Extend the list of disconnected client errors in HttpWebHandlerAdapter to include the Reactor Netty AbortedException as well exceptions with the message "connection reset by peer". Closes gh-21790 --- .../server/adapter/HttpWebHandlerAdapter.java | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java b/spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java index 594b4ef989..fafc3b7148 100644 --- a/spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java +++ b/spring-web/src/main/java/org/springframework/web/server/adapter/HttpWebHandlerAdapter.java @@ -69,17 +69,9 @@ public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHa private static final String DISCONNECTED_CLIENT_LOG_CATEGORY = "org.springframework.web.server.DisconnectedClient"; - /** - * Tomcat: ClientAbortException or EOFException - * Jetty: EofException - * WildFly, GlassFish: java.io.IOException "Broken pipe" (already covered) - *

TODO: - * This definition is currently duplicated between HttpWebHandlerAdapter - * and AbstractSockJsSession. It is a candidate for a common utility class. - * @see #isDisconnectedClientError(Throwable) - */ - private static final Set DISCONNECTED_CLIENT_EXCEPTIONS = - new HashSet<>(Arrays.asList("ClientAbortException", "EOFException", "EofException")); + // Similar declaration exists in AbstractSockJsSession.. + private static final Set DISCONNECTED_CLIENT_EXCEPTIONS = new HashSet<>( + Arrays.asList("AbortedException", "ClientAbortException", "EOFException", "EofException")); private static final Log logger = LogFactory.getLog(HttpWebHandlerAdapter.class); @@ -299,8 +291,11 @@ public class HttpWebHandlerAdapter extends WebHandlerDecorator implements HttpHa private boolean isDisconnectedClientError(Throwable ex) { String message = NestedExceptionUtils.getMostSpecificCause(ex).getMessage(); - if (message != null && message.toLowerCase().contains("broken pipe")) { - return true; + if (message != null) { + String text = message.toLowerCase(); + if (text.contains("broken pipe") || text.contains("connection reset by peer")) { + return true; + } } return DISCONNECTED_CLIENT_EXCEPTIONS.contains(ex.getClass().getSimpleName()); } -- GitLab