From 1e9f50955cf299ecbdeb2aab00bf6c951f8b53d1 Mon Sep 17 00:00:00 2001 From: Jerome Louvel <374450+jlouvel@users.noreply.github.com> Date: Tue, 3 Nov 2026 13:24:15 -0500 Subject: [PATCH] Drop the flush workaround from the Smithy server spike The Netty connectors now flush each full output buffer (#1632), so the host copies the payload without flushing, and the streaming test checks the core fix through Smithy. Co-Authored-By: Claude Opus 5.5 Signed-off-by: Jerome Louvel <374450+jlouvel@users.noreply.github.com> --- .../connector/SmithyServerSpikeTestCase.java | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/org.restlet/src/test/java/org/restlet/engine/connector/SmithyServerSpikeTestCase.java b/org.restlet/src/test/java/org/restlet/engine/connector/SmithyServerSpikeTestCase.java index d0cf13d0d7..caa457f78a 100644 --- a/org.restlet/src/test/java/org/restlet/engine/connector/SmithyServerSpikeTestCase.java +++ b/org.restlet/src/test/java/org/restlet/engine/connector/SmithyServerSpikeTestCase.java @@ -313,7 +313,10 @@ void blockingOperationsDoNotSerializeCalls() throws Exception { } } - /** A streaming payload starts reaching the client before the operation's stream ends. */ + /** + * A streaming payload starts reaching the client before the operation's stream ends: the host + * copies it without flushing, and the connector sends each full buffer (issue #1632). + */ @Test void streamingOutputIsNotBufferedWhole() throws Exception { CountDownLatch firstChunkRead = new CountDownLatch(1); @@ -510,30 +513,14 @@ private static void write(HttpJob job, Response response) { : body.contentLength()) { @Override public void write(java.io.OutputStream out) throws IOException { - copy(body.asInputStream(), out); + try (InputStream in = body.asInputStream()) { + in.transferTo(out); + } } }; response.setEntity(entity); } } - - /** - * Copies a payload, flushing whenever the source has nothing more available: the connector - * only flushes full buffers once it holds more than its high water mark, so a producer - * pausing mid-stream would otherwise hold back what it already produced. - */ - private static void copy(InputStream in, java.io.OutputStream out) throws IOException { - try (in) { - byte[] buffer = new byte[16 * 1024]; - int count; - while ((count = in.read(buffer)) > 0) { - out.write(buffer, 0, count); - if (in.available() == 0) { - out.flush(); - } - } - } - } } /** A server service built from the model, like smithy-java's ProxyService, without codegen. */