diff --git a/servlet/src/main/java/io/undertow/servlet/spec/ServletPrintWriter.java b/servlet/src/main/java/io/undertow/servlet/spec/ServletPrintWriter.java index 49609f7dd0..64b426c9e0 100644 --- a/servlet/src/main/java/io/undertow/servlet/spec/ServletPrintWriter.java +++ b/servlet/src/main/java/io/undertow/servlet/spec/ServletPrintWriter.java @@ -180,8 +180,10 @@ public void write(final CharBuffer input) { remainingContentLength -= writtenLength; outputStream.updateWritten(writtenLength); if (result.isOverflow() || !buffer.hasRemaining()) { + final int remainingBytesBeforeFlush = buffer.remaining(); outputStream.flushInternal(); - if (buffer.remaining() == remaining) { + if (buffer.remaining() == remainingBytesBeforeFlush) { + // no progress has been made, set error to true error = true; return; }