Skip to content

Commit ef5149c

Browse files
committed
Fix intermittently failing test.
If you fake a blocking with async write while processing a read there is a strong chance of a deadlock. The read will be holding a lock on the SocketWrapper. If the async write does not complete in-line it will perform a dispatch when it is ready to write and that dispatch will try to obtain a lock on the socket wrapper. The lock on that opbject is already held and a deadlock will follow.
1 parent 2e3a708 commit ef5149c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

test/org/apache/tomcat/websocket/pojo/TestEncodingDecoding.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ public static class MessagesServer {
403403
@OnMessage
404404
public String onMessage(String message, Session session) throws Exception {
405405
received.add(message);
406-
session.getAsyncRemote().sendText(MESSAGE_ONE).get();
406+
session.getBasicRemote().sendText(MESSAGE_ONE);
407407
return message;
408408
}
409409

@@ -425,9 +425,9 @@ public static class BatchedServer {
425425
@OnMessage
426426
public String onMessage(String message, Session session) throws IOException {
427427
received.add(message);
428-
session.getAsyncRemote().setBatchingAllowed(true);
429-
session.getAsyncRemote().sendText(MESSAGE_ONE);
430-
session.getAsyncRemote().setBatchingAllowed(false);
428+
session.getBasicRemote().setBatchingAllowed(true);
429+
session.getBasicRemote().sendText(MESSAGE_ONE);
430+
session.getBasicRemote().setBatchingAllowed(false);
431431
return MESSAGE_TWO;
432432
}
433433

0 commit comments

Comments
 (0)