diff --git a/src/test/java/io/floci/aws/services/redshift/proxy/S3CopySimulatorTest.java b/src/test/java/io/floci/aws/services/redshift/proxy/S3CopySimulatorTest.java index f6f28bb438..fd8a74f67e 100644 --- a/src/test/java/io/floci/aws/services/redshift/proxy/S3CopySimulatorTest.java +++ b/src/test/java/io/floci/aws/services/redshift/proxy/S3CopySimulatorTest.java @@ -23,7 +23,6 @@ import java.io.OutputStream; import java.net.InetAddress; import java.net.ServerSocket; import java.net.Socket; -import java.net.SocketTimeoutException; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; @@ -432,6 +431,12 @@ class S3CopySimulatorTest { }); } + private void assertNoMoreClientBytes() throws IOException { + // The simulator has returned. Half-closing its output puts EOF after any buffered response bytes. + simClient.shutdownOutput(); + assertEquals(-1, testClient.getInputStream().read(), "unexpected data after ReadyForQuery"); + } + private void joinBackend(Thread t) throws InterruptedException { t.join(); Throwable failure = backendFailure.get(); @@ -1013,8 +1018,7 @@ class S3CopySimulatorTest { PostgresWireDecoder in = new PostgresWireDecoder(testClient.getInputStream()); assertEquals('E', in.nextMessage().type()); assertEquals('Z', in.nextMessage().type()); - testClient.setSoTimeout(400); - assertThrows(SocketTimeoutException.class, () -> testClient.getInputStream().read()); + assertNoMoreClientBytes(); } @Test @@ -1131,9 +1135,7 @@ class S3CopySimulatorTest { PostgresWireDecoder in = new PostgresWireDecoder(testClient.getInputStream()); assertEquals('E', in.nextMessage().type()); assertEquals('Z', in.nextMessage().type()); - testClient.setSoTimeout(400); - assertThrows(SocketTimeoutException.class, () -> testClient.getInputStream().read(), - "no leftover or duplicate messages should reach client"); + assertNoMoreClientBytes(); } finally { S3CopySimulator.UNLOAD_TARGET_FILE_BYTES = saved; } @@ -1733,9 +1735,7 @@ class S3CopySimulatorTest { PostgresWireDecoder in = new PostgresWireDecoder(testClient.getInputStream()); assertEquals('E', in.nextMessage().type()); assertEquals('Z', in.nextMessage().type()); - testClient.setSoTimeout(400); - assertThrows(SocketTimeoutException.class, () -> testClient.getInputStream().read(), - "no second response should follow"); + assertNoMoreClientBytes(); } @Test