From 370a81a9850bd59e9cbbdc276660092ef4145a98 Mon Sep 17 00:00:00 2001 From: Bryce Anderson Date: Tue, 14 Nov 2023 10:38:21 -0700 Subject: [PATCH] http-netty: Fix flaky SslAndNonSslConnectionsTest (#2755) Motivation We have a flaky test. It appears to be a rare case of netty sending an IOException down the `exceptionCaught` netty pipeline pathway that isn't handled. Modifications - Widen what we expect in the test to IOException --- .../servicetalk/http/netty/SslAndNonSslConnectionsTest.java | 6 +++--- .../netty/internal/StacklessClosedChannelException.java | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/servicetalk-http-netty/src/test/java/io/servicetalk/http/netty/SslAndNonSslConnectionsTest.java b/servicetalk-http-netty/src/test/java/io/servicetalk/http/netty/SslAndNonSslConnectionsTest.java index 250069babb..2fd20cef1e 100644 --- a/servicetalk-http-netty/src/test/java/io/servicetalk/http/netty/SslAndNonSslConnectionsTest.java +++ b/servicetalk-http-netty/src/test/java/io/servicetalk/http/netty/SslAndNonSslConnectionsTest.java @@ -35,8 +35,8 @@ import org.junit.jupiter.api.Test; import org.mockito.stubbing.Answer; +import java.io.IOException; import java.net.InetAddress; -import java.nio.channels.ClosedChannelException; import java.security.cert.CertificateException; import javax.annotation.Nullable; import javax.net.ssl.SSLHandshakeException; @@ -137,7 +137,7 @@ void nonSecureClientToSecureServerClosesConnection() throws Exception { assert secureServerCtx != null; try (BlockingHttpClient client = HttpClients.forSingleAddress(serverHostAndPort(secureServerCtx)) .buildBlocking()) { - assertThrows(ClosedChannelException.class, () -> client.request(client.get("/"))); + assertThrows(IOException.class, () -> client.request(client.get("/"))); } } @@ -148,7 +148,7 @@ void secureClientToNonSecureServerClosesConnection() throws Exception { .sslConfig(new ClientSslConfigBuilder(DefaultTestCerts::loadServerCAPem) .peerHost(serverPemHostname()).build()) .buildBlocking()) { - assertThrows(ClosedChannelException.class, () -> client.request(client.get("/"))); + assertThrows(IOException.class, () -> client.request(client.get("/"))); } } diff --git a/servicetalk-transport-netty-internal/src/main/java/io/servicetalk/transport/netty/internal/StacklessClosedChannelException.java b/servicetalk-transport-netty-internal/src/main/java/io/servicetalk/transport/netty/internal/StacklessClosedChannelException.java index 3242897b3d..a12007402d 100644 --- a/servicetalk-transport-netty-internal/src/main/java/io/servicetalk/transport/netty/internal/StacklessClosedChannelException.java +++ b/servicetalk-transport-netty-internal/src/main/java/io/servicetalk/transport/netty/internal/StacklessClosedChannelException.java @@ -20,7 +20,7 @@ import java.nio.channels.ClosedChannelException; /** - * {@link ClosedChannelException} that will not not fill in the stacktrace but use a cheaper way of producing + * {@link ClosedChannelException} that will not fill in the stacktrace but use a cheaper way of producing * limited stacktrace details for the user. */ public final class StacklessClosedChannelException extends ClosedChannelException {