Skip to content

Commit 6411db3

Browse files
millemsdagnir
authored andcommitted
Improved error messaging when a connection is closed. Fixes #1260.
1 parent bedbb13 commit 6411db3

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"category": "Netty NIO HTTP Client",
3+
"type": "feature",
4+
"description": "Improved error messaging when a connection is closed. Fixes [#1260](https://github.com/aws/aws-sdk-java-v2/issues/1260)."
5+
}

http-clients/netty-nio-client/src/main/java/software/amazon/awssdk/http/nio/netty/internal/NettyRequestExecutor.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
import java.io.IOException;
4848
import java.net.URI;
4949
import java.nio.ByteBuffer;
50+
import java.nio.channels.ClosedChannelException;
5051
import java.time.Duration;
5152
import java.util.Optional;
5253
import java.util.concurrent.CompletableFuture;
@@ -262,6 +263,8 @@ private Throwable decorateException(Throwable originalCause) {
262263
return new IOException("Read timed out", originalCause);
263264
} else if (originalCause instanceof WriteTimeoutException) {
264265
return new IOException("Write timed out", originalCause);
266+
} else if (originalCause instanceof ClosedChannelException) {
267+
return new IOException(getMessageForClosedChannel(), originalCause);
265268
}
266269

267270
return originalCause;
@@ -320,6 +323,12 @@ private String getMessageForTooManyAcquireOperationsError() {
320323
+ "AWS, or by increasing the number of hosts sending requests.";
321324
}
322325

326+
private String getMessageForClosedChannel() {
327+
return "The channel was closed. This may have been done by the client (e.g. because the request was aborted), " +
328+
"by the service (e.g. because the request took too long or the client tried to write on a read-only socket), " +
329+
"or by an intermediary party (e.g. because the channel was idle for too long).";
330+
}
331+
323332
/**
324333
* Close and release the channel back to the pool.
325334
*

0 commit comments

Comments
 (0)