Skip to content

Commit e0e0343

Browse files
committed
fix(web): handle HttpMessageNotWritableException in DisconnectedClientHelper
1 parent 6f08c0b commit e0e0343

3 files changed

Lines changed: 11 additions & 1 deletion

File tree

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ version=7.1.0-SNAPSHOT
33
org.gradle.caching=true
44
org.gradle.jvmargs=-Xmx2048m
55
org.gradle.parallel=true
6+
org.gradle.java.installations.paths=E:\\jdk25\\loom-ea-25-loom+1-11
67

78
kotlinVersion=2.3.20
89
byteBuddyVersion=1.17.6

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
public class DisconnectedClientHelper {
4343

4444
private static final Set<String> EXCEPTION_PHRASES =
45-
Set.of("broken pipe", "connection reset by peer");
45+
Set.of("broken pipe", "connection reset by peer",
46+
"response may not be written");
4647

4748
private static final Set<String> EXCEPTION_TYPE_NAMES =
4849
Set.of("AbortedException", "ClientAbortException",

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import org.springframework.web.client.ResourceAccessException;
3535
import org.springframework.web.context.request.async.AsyncRequestNotUsableException;
3636
import org.springframework.web.testfixture.http.MockHttpInputMessage;
37+
import org.springframework.http.converter.HttpMessageNotWritableException;
3738

3839
import static org.assertj.core.api.Assertions.assertThat;
3940

@@ -99,4 +100,11 @@ void nullException() {
99100
assertThat(DisconnectedClientHelper.isClientDisconnectedException(null)).isFalse();
100101
}
101102

103+
@Test // gh-36421
104+
void httpMessageNotWritableFromClosedConnection() {
105+
IOException cause = new IOException("The response may not be written to once it has been closed");
106+
Exception ex = new HttpMessageNotWritableException("Could not write JSON", cause);
107+
assertThat(DisconnectedClientHelper.isClientDisconnectedException(ex)).isTrue();
108+
}
109+
102110
}

0 commit comments

Comments
 (0)