Browse Source

Accept `SocketException` in `Netty4HttpClient` (#105690)

It's also possible to get a `Connection reset` if the server closes the
channel while we're still sending requests. This commit handles that
case in these tests.
David Turner 1 year ago
parent
commit
d4263c2d4e

+ 2 - 1
modules/transport-netty4/src/test/java/org/elasticsearch/http/netty4/Netty4HttpClient.java

@@ -40,6 +40,7 @@ import org.elasticsearch.transport.netty4.NettyAllocator;
 
 import java.io.Closeable;
 import java.net.SocketAddress;
+import java.net.SocketException;
 import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -190,7 +191,7 @@ class Netty4HttpClient implements Closeable {
 
                 @Override
                 public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
-                    if (cause instanceof PrematureChannelClosureException) {
+                    if (cause instanceof PrematureChannelClosureException || cause instanceof SocketException) {
                         // no more requests coming, so fast-forward the latch
                         fastForward();
                     } else {