tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject [tomcat] 06/06: Alter approach in an attempt to reduce CI failures
Date Fri, 21 Aug 2020 16:51:06 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit 603e9a840ef3ecb4f72a6583d9e986d48f77d871
Author: Mark Thomas <markt@apache.org>
AuthorDate: Fri Aug 21 16:51:35 2020 +0100

    Alter approach in an attempt to reduce CI failures
---
 .../catalina/nonblocking/TestNonBlockingAPI.java   | 24 ++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java b/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
index b1ef421..c964224 100644
--- a/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
+++ b/test/org/apache/catalina/nonblocking/TestNonBlockingAPI.java
@@ -322,7 +322,10 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
         TesterAccessLogValve alv = new TesterAccessLogValve();
         ctx.getPipeline().addValve(alv);
 
-        NBWriteServlet servlet = new NBWriteServlet();
+        // Some CI platforms appear to have particularly large write buffers
+        // and appear to ignore the socket.txBufSize below. Therefore, configure
+        // configure the Servlet to keep writing until an error is encountered.
+        NBWriteServlet servlet = new NBWriteServlet(true);
         String servletName = NBWriteServlet.class.getName();
         Tomcat.addServlet(ctx, servletName, servlet);
         ctx.addServletMappingDecoded("/", servletName);
@@ -541,9 +544,20 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
     @WebServlet(asyncSupported = true)
     public static class NBWriteServlet extends TesterServlet {
         private static final long serialVersionUID = 1L;
+        private final boolean unlimited;
         public transient volatile TestWriteListener wlistener;
         public transient volatile TestReadListener rlistener;
 
+        public NBWriteServlet() {
+            this(false);
+        }
+
+
+        public NBWriteServlet(boolean unlimited) {
+            this.unlimited = unlimited;
+        }
+
+
         @Override
         protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException,
IOException {
             // step 1 - start async
@@ -577,7 +591,7 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
             in.setReadListener(rlistener);
             ServletOutputStream out = resp.getOutputStream();
             resp.setBufferSize(200 * 1024);
-            wlistener = new TestWriteListener(actx);
+            wlistener = new TestWriteListener(actx, unlimited);
             out.setWriteListener(wlistener);
         }
 
@@ -729,18 +743,20 @@ public class TestNonBlockingAPI extends TomcatBaseTest {
 
     private static class TestWriteListener implements WriteListener {
         AsyncContext ctx;
+        private final boolean unlimited;
         int written = 0;
         public volatile boolean onErrorInvoked = false;
 
-        public TestWriteListener(AsyncContext ctx) {
+        public TestWriteListener(AsyncContext ctx, boolean unlimted) {
             this.ctx = ctx;
+            this.unlimited = unlimted;
         }
 
         @Override
         public void onWritePossible() throws IOException {
             long start = System.currentTimeMillis();
             int before = written;
-            while (written < WRITE_SIZE &&
+            while ((written < WRITE_SIZE || unlimited) &&
                     ctx.getResponse().getOutputStream().isReady()) {
                 ctx.getResponse().getOutputStream().write(
                         DATA, written, CHUNK_SIZE);


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message