From 203fa7519692a3d12a4eca73765ba6592b164fd3 Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Tue, 18 Jun 2024 16:42:59 +0200 Subject: [PATCH] Support all "connection reset" phrases in DisconnectedClientHelper Prior to this commit, the isClientDisconnectedException() method in DisconnectedClientHelper checked whether the message of the ultimate exception in an exception chain contained one of the phrases "broken pipe" or "connection reset by peer". However, that failed to match if the exception message contained "Connection reset", which is the case for the SocketException thrown by throwConnectionReset() in sun.nio.ch.SocketChannelImpl. This commit therefore replaces the "connection reset by peer" phrase with "connection reset" in order to support all exception messages containing "connection reset". Closes gh-33064 --- .../springframework/web/util/DisconnectedClientHelper.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/util/DisconnectedClientHelper.java b/spring-web/src/main/java/org/springframework/web/util/DisconnectedClientHelper.java index 58da642b8cf..84b53ce8f4a 100644 --- a/spring-web/src/main/java/org/springframework/web/util/DisconnectedClientHelper.java +++ b/spring-web/src/main/java/org/springframework/web/util/DisconnectedClientHelper.java @@ -36,7 +36,7 @@ import org.springframework.util.Assert; public class DisconnectedClientHelper { private static final Set EXCEPTION_PHRASES = - Set.of("broken pipe", "connection reset by peer"); + Set.of("broken pipe", "connection reset"); private static final Set EXCEPTION_TYPE_NAMES = Set.of("AbortedException", "ClientAbortException", @@ -73,11 +73,12 @@ public class DisconnectedClientHelper { /** * Whether the given exception indicates the client has gone away. - * Known cases covered: + *

Known cases covered: *

*/ public static boolean isClientDisconnectedException(Throwable ex) {