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
The following commit(s) were added to refs/heads/8.5.x by this push: new 2a13558 Fix various potential timing issues with this test. 2a13558 is described below commit 2a135586b96fef8d1ea14a3c0045e7f90a399c48 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. --- .../tomcat/websocket/TestWsSessionSuspendResume.java | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/test/org/apache/tomcat/websocket/TestWsSessionSuspendResume.java b/test/org/apache/tomcat/websocket/TestWsSessionSuspendResume.java index f6ea3b9..8901512 100644 --- a/test/org/apache/tomcat/websocket/TestWsSessionSuspendResume.java +++ b/test/org/apache/tomcat/websocket/TestWsSessionSuspendResume.java @@ -29,8 +29,6 @@ import javax.websocket.ContainerProvider; import javax.websocket.Endpoint; import javax.websocket.EndpointConfig; import javax.websocket.MessageHandler; -import javax.websocket.SendHandler; -import javax.websocket.SendResult; import javax.websocket.Session; import javax.websocket.WebSocketContainer; import javax.websocket.server.ServerEndpointConfig; @@ -76,7 +74,7 @@ public class TestWsSessionSuspendResume extends WebSocketBaseTest { } }); for (int i = 0; i < 8; i++) { - wsSession.getAsyncRemote().sendText("echo"); + wsSession.getBasicRemote().sendText("echo"); } boolean latchResult = latch.await(30, TimeUnit.SECONDS); @@ -144,15 +142,13 @@ public class TestWsSessionSuspendResume extends WebSocketBaseTest { void addMessage(String message) { if (messages.size() == count) { ((WsSession) session).suspend(); - session.getAsyncRemote().sendText(messages.toString(), new SendHandler() { - - @Override - public void onResult(SendResult result) { - ((WsSession) session).resume(); - Assert.assertTrue(result.isOK()); - } - }); - messages.clear(); + try { + session.getBasicRemote().sendText(messages.toString()); + messages.clear(); + ((WsSession) session).resume(); + } catch (IOException e) { + Assert.fail(); + } } else { messages.add(message); } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org