diff --git a/core/src/main/java/io/undertow/conduits/WriteTimeoutStreamSinkConduit.java b/core/src/main/java/io/undertow/conduits/WriteTimeoutStreamSinkConduit.java index 8398c8b43c..5971041dd4 100644 --- a/core/src/main/java/io/undertow/conduits/WriteTimeoutStreamSinkConduit.java +++ b/core/src/main/java/io/undertow/conduits/WriteTimeoutStreamSinkConduit.java @@ -109,7 +109,15 @@ private void handleWriteTimeout(final long ret) throws IOException { long expireTimeVar = expireTime; if (expireTimeVar != -1 && currentTime > expireTimeVar) { this.expireTime = -1; + //shutdown write will call AbstractFramedStreamSinkConduit#queueCloseFrames. In some cases it will schedule + //additional packets to adhere to protocol, we need to flush content( this would happen later, if not for + //subsequent close connection.getSinkChannel().shutdownWrites(); + try { + connection.getSinkChannel().flush(); + } catch(IOException e) { + UndertowLogger.REQUEST_LOGGER.ioException(e); + } IoUtils.safeClose(connection); throw new ClosedChannelException(); }