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

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


The following commit(s) were added to refs/heads/11.0.x by this push:
     new bf0fddd4c3 Stabilize TestSwallowAbortedUploads.testChunkedPUTLimit
bf0fddd4c3 is described below

commit bf0fddd4c3464718b6f335a12a81705113dc3830
Author: Dimitrios Soumis <[email protected]>
AuthorDate: Fri Sep 19 21:06:53 2025 +0300

    Stabilize TestSwallowAbortedUploads.testChunkedPUTLimit
    
    The test assumed write would fail once the server stopped swallowing, but  
the client could finish buffering data before the close was observed, so no 
SocketException was thrown during the write and the assertion failed.
---
 .../apache/catalina/core/TestSwallowAbortedUploads.java | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/test/org/apache/catalina/core/TestSwallowAbortedUploads.java 
b/test/org/apache/catalina/core/TestSwallowAbortedUploads.java
index c3ac752598..a00647d2cd 100644
--- a/test/org/apache/catalina/core/TestSwallowAbortedUploads.java
+++ b/test/org/apache/catalina/core/TestSwallowAbortedUploads.java
@@ -23,6 +23,7 @@ import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.io.Writer;
 import java.net.Socket;
+import java.net.SocketException;
 import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.Collection;
@@ -423,7 +424,7 @@ public class TestSwallowAbortedUploads extends 
TomcatBaseTest {
 
         tomcat.start();
 
-        Exception writeEx = null;
+        SocketException writeEx = null;
         Exception readEx = null;
         String responseLine = null;
 
@@ -442,7 +443,8 @@ public class TestSwallowAbortedUploads extends 
TomcatBaseTest {
                     writer.write("10\r\n");
                     writer.write("0123456789ABCDEF\r\n");
                 }
-            } catch (Exception e) {
+                writer.flush();
+            } catch (SocketException e) {
                 writeEx = e;
             }
 
@@ -454,6 +456,17 @@ public class TestSwallowAbortedUploads extends 
TomcatBaseTest {
             } catch (IOException ioe) {
                 readEx = ioe;
             }
+
+            // If no exception was thrown during the big write,
+            // write once more because the close may have not been observed
+            if (limit && writeEx == null) {
+                try {
+                    writer.write("1\r\n");
+                    writer.flush();
+                } catch (SocketException e) {
+                    writeEx = e;
+                }
+            }
         }
 
         if (limit) {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to