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 a62f6312bbb..5779f3ec6b2 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
@@ -24,6 +24,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.core.NestedExceptionUtils;
+import org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
@@ -100,7 +101,11 @@ public class DisconnectedClientHelper {
*
IOException "Broken pipe" or "connection reset by peer"
*
*/
- public static boolean isClientDisconnectedException(Throwable ex) {
+ public static boolean isClientDisconnectedException(@Nullable Throwable ex) {
+ if (ex == null) {
+ return false;
+ }
+
Throwable currentEx = ex;
Throwable lastEx = null;
while (currentEx != null && currentEx != lastEx) {
diff --git a/spring-web/src/test/java/org/springframework/web/util/DisconnectedClientHelperTests.java b/spring-web/src/test/java/org/springframework/web/util/DisconnectedClientHelperTests.java
index 296a1920927..0d79da9ebf4 100644
--- a/spring-web/src/test/java/org/springframework/web/util/DisconnectedClientHelperTests.java
+++ b/spring-web/src/test/java/org/springframework/web/util/DisconnectedClientHelperTests.java
@@ -90,4 +90,9 @@ public class DisconnectedClientHelperTests {
assertThat(DisconnectedClientHelper.isClientDisconnectedException(ex)).isFalse();
}
+ @Test // gh-34533
+ void nullException() {
+ assertThat(DisconnectedClientHelper.isClientDisconnectedException(null)).isFalse();
+ }
+
}