This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 0871cda88209cc372f9f8c0a3bba419f9f2b344d Author: remm <r...@apache.org> AuthorDate: Wed Jan 29 10:56:09 2025 +0100 Work around available tricks available() needs to be called even though the first read returned 0 bytes. Going through everything it seems "normal" and there is no real workaround. --- .../http11/filters/TestChunkedInputFilter.java | 33 +++++++++++----------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/test/org/apache/coyote/http11/filters/TestChunkedInputFilter.java b/test/org/apache/coyote/http11/filters/TestChunkedInputFilter.java index 225a84fee7..86071ad20d 100644 --- a/test/org/apache/coyote/http11/filters/TestChunkedInputFilter.java +++ b/test/org/apache/coyote/http11/filters/TestChunkedInputFilter.java @@ -839,22 +839,23 @@ public class TestChunkedInputFilter extends TomcatBaseTest { byte[] buf = new byte[1024]; do { int n = is.read(buf); - if (n <= 0) { + if (n < 0) { break; + } else if (n > 0) { + String line = new String(buf, 0, n, StandardCharsets.UTF_8); + Assert.assertTrue(line.length() > 0); + long thisRead = System.nanoTime(); + if (lineCount > 0) { + /* + * After the first line, look for a pause of at least 800ms between reads. + */ + if ((thisRead - lastRead) > TimeUnit.MILLISECONDS.toNanos(800)) { + pauseCount++; + } + } + lastRead = thisRead; + lineCount++; } - String line = new String(buf, 0, n, StandardCharsets.UTF_8); - Assert.assertTrue(line.length() > 0); - long thisRead = System.nanoTime(); - if (lineCount > 0) { - /* - * After the first line, look for a pause of at least 800ms between reads. - */ - if ((thisRead - lastRead) > TimeUnit.MILLISECONDS.toNanos(800)) { - pauseCount++; - } - } - lastRead = thisRead; - lineCount++; } while (is.isReady()); } @@ -965,7 +966,7 @@ public class TestChunkedInputFilter extends TomcatBaseTest { SimpleHttpClient.CRLF + "7" + SimpleHttpClient.CRLF + "DATA01\n", SimpleHttpClient.CRLF + - "7"/*, */ + SimpleHttpClient.CRLF + + "7", SimpleHttpClient.CRLF + "DATA02\n" + SimpleHttpClient.CRLF, "7" + SimpleHttpClient.CRLF + // Split the CRLF between writes @@ -973,7 +974,7 @@ public class TestChunkedInputFilter extends TomcatBaseTest { SimpleHttpClient.LF + "7" + SimpleHttpClient.CRLF + "DATA04\n", SimpleHttpClient.CRLF + - "13" + SimpleHttpClient.CRLF/*, */ + + "13" + SimpleHttpClient.CRLF, "DATA05DATA05DATA05\n" + SimpleHttpClient.CRLF + "0" + SimpleHttpClient.CRLF + SimpleHttpClient.CRLF}; --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org