From 5bd042f0051ea190887b272e88d951d500c51726 Mon Sep 17 00:00:00 2001 From: Tomasz Adamski Date: Thu, 27 Aug 2026 11:39:51 +0200 Subject: [PATCH] [WEJBHTTP-161] Fix END_STREAM not sent over HTTP/2 when request body fills exactly one buffer In WildflyClientOutputStream.handleEvent, suspendWrites() and FLAG_WRITING were cleared before the final flush() was attempted. If flush returned false (deferred, normal under HTTP/2 with concurrent requests on a shared connection), the retry mechanism was already disabled and the stream was silently abandoned, causing the server to never receive END_STREAM and stall until timeout. Defer suspendWrites() and clearing FLAG_WRITING until after a successful flush. If flush returns false, return early keeping write callbacks active so the listener retries when the channel becomes writable. This mirrors the handling in the neighboring empty-buffer branch corrected in WEJBHTTP-45. --- .../common/WildflyClientOutputStream.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/org/wildfly/httpclient/common/WildflyClientOutputStream.java b/common/src/main/java/org/wildfly/httpclient/common/WildflyClientOutputStream.java index 2dd3376e..1899225f 100644 --- a/common/src/main/java/org/wildfly/httpclient/common/WildflyClientOutputStream.java +++ b/common/src/main/java/org/wildfly/httpclient/common/WildflyClientOutputStream.java @@ -94,16 +94,17 @@ public void handleEvent(StreamSinkChannel streamSinkChannel) { return; } } - lock.notifyAll(); - streamSinkChannel.suspendWrites(); - state &= ~FLAG_WRITING; pooledBuffer.close(); pooledBuffer = null; + if (closed && !streamSinkChannel.flush()) { + return; + } if (closed) { - if (streamSinkChannel.flush()) { - state |= FLAG_DONE; - } + state |= FLAG_DONE; } + streamSinkChannel.suspendWrites(); + state &= ~FLAG_WRITING; + lock.notifyAll(); } } catch (IOException e) { if (pooledBuffer != null) {