Skip to content

Commit 09ae080

Browse files
committed
isDisconnectedClientException protected for null
Closes gh-34533
1 parent 70a1b2f commit 09ae080

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

spring-web/src/main/java/org/springframework/web/util/DisconnectedClientHelper.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.apache.commons.logging.LogFactory;
2525

2626
import org.springframework.core.NestedExceptionUtils;
27+
import org.springframework.lang.Nullable;
2728
import org.springframework.util.Assert;
2829
import org.springframework.util.ClassUtils;
2930

@@ -100,7 +101,11 @@ else if (logger.isDebugEnabled()) {
100101
* <li>IOException "Broken pipe" or "connection reset by peer"
101102
* </ul>
102103
*/
103-
public static boolean isClientDisconnectedException(Throwable ex) {
104+
public static boolean isClientDisconnectedException(@Nullable Throwable ex) {
105+
if (ex == null) {
106+
return false;
107+
}
108+
104109
Throwable currentEx = ex;
105110
Throwable lastEx = null;
106111
while (currentEx != null && currentEx != lastEx) {

spring-web/src/test/java/org/springframework/web/util/DisconnectedClientHelperTests.java

+5
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,9 @@ void onwardClientDisconnectedExceptionType() {
9090
assertThat(DisconnectedClientHelper.isClientDisconnectedException(ex)).isFalse();
9191
}
9292

93+
@Test // gh-34533
94+
void nullException() {
95+
assertThat(DisconnectedClientHelper.isClientDisconnectedException(null)).isFalse();
96+
}
97+
9398
}

0 commit comments

Comments
 (0)