You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2020/06/25 18:31:58 UTC

[tomcat] branch 9.0.x updated: Fix various potential timing issues with this test.

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

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


The following commit(s) were added to refs/heads/9.0.x by this push:
     new 842df87  Fix various potential timing issues with this test.
842df87 is described below

commit 842df87563a64363441665ddde3727c2bc5ec4c1
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Thu Jun 25 19:28:02 2020 +0100

    Fix various potential timing issues with this test.
    
    On the client side messages were sent via the async API in a loop. That
    creates a risk of breakage as it is not permitted to send the next
    message until the previous message completes and the client wasn't
    checking that the previous message had completed. SWitching to the basic
    API avoids this.
    
    On the server side, resume() was being called inside an async callback.
    It was possible for resume() to be called and one or more messages to be
    processed before the call to messages.clear(). Switching to the basic
    API allows the order to be controlled correctly.
---
 .../apache/tomcat/websocket/TestWsSessionSuspendResume.java  | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/test/org/apache/tomcat/websocket/TestWsSessionSuspendResume.java b/test/org/apache/tomcat/websocket/TestWsSessionSuspendResume.java
index 8af8679..41d8d72 100644
--- a/test/org/apache/tomcat/websocket/TestWsSessionSuspendResume.java
+++ b/test/org/apache/tomcat/websocket/TestWsSessionSuspendResume.java
@@ -69,7 +69,7 @@ public class TestWsSessionSuspendResume extends WebSocketBaseTest {
             latch.countDown();
         });
         for (int i = 0; i < 8; i++) {
-            wsSession.getAsyncRemote().sendText("echo");
+            wsSession.getBasicRemote().sendText("echo");
         }
 
         boolean latchResult = latch.await(30, TimeUnit.SECONDS);
@@ -131,11 +131,13 @@ public class TestWsSessionSuspendResume extends WebSocketBaseTest {
         void addMessage(String message) {
             if (messages.size() == count) {
                 ((WsSession) session).suspend();
-                session.getAsyncRemote().sendText(messages.toString(), result -> {
+                try {
+                    session.getBasicRemote().sendText(messages.toString());
+                    messages.clear();
                     ((WsSession) session).resume();
-                    Assert.assertTrue(result.isOK());
-                });
-                messages.clear();
+                } catch (IOException e) {
+                    Assert.fail();
+                }
             } else {
                 messages.add(message);
             }


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