This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch 11.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 86862a7544bded47734b565e19de5f1b7e8f5ea1
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

Reply via email to