isDisconnectedClientException protected for null

Closes gh-34533
This commit is contained in:
rstoyanchev
2025-03-04 15:18:17 +00:00
parent 70a1b2fae3
commit 09ae080b99
2 changed files with 11 additions and 1 deletions

View File

@@ -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 {
* <li>IOException "Broken pipe" or "connection reset by peer"
* </ul>
*/
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) {

View File

@@ -90,4 +90,9 @@ public class DisconnectedClientHelperTests {
assertThat(DisconnectedClientHelper.isClientDisconnectedException(ex)).isFalse();
}
@Test // gh-34533
void nullException() {
assertThat(DisconnectedClientHelper.isClientDisconnectedException(null)).isFalse();
}
}