diff --git a/deployment/src/test/java/com/github/mcollovati/quarkus/hilla/deployment/HillaPushClient.java b/deployment/src/test/java/com/github/mcollovati/quarkus/hilla/deployment/HillaPushClient.java index a8983975..963d2462 100644 --- a/deployment/src/test/java/com/github/mcollovati/quarkus/hilla/deployment/HillaPushClient.java +++ b/deployment/src/test/java/com/github/mcollovati/quarkus/hilla/deployment/HillaPushClient.java @@ -29,7 +29,7 @@ import java.util.LinkedHashMap; import java.util.List; import java.util.UUID; -import java.util.concurrent.LinkedBlockingDeque; +import java.util.concurrent.ArrayBlockingQueue; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Consumer; @@ -48,7 +48,7 @@ public class HillaPushClient extends Endpoint implements MessageHandler.Whole messages = new LinkedBlockingDeque<>(); + final ArrayBlockingQueue messages = new ArrayBlockingQueue<>(1000); final String id; private final String endpointName; @@ -69,7 +69,7 @@ public HillaPushClient(String endpointName, String methodName, Object... paramet public void onOpen(Session session, EndpointConfig config) { LOGGER.trace("Client {} connected", id); this.session = session; - messages.add("CONNECT"); + messages.offer("CONNECT"); session.addMessageHandler(this); session.getAsyncRemote().sendText(createSubscribeMessage()); } @@ -77,7 +77,7 @@ public void onOpen(Session session, EndpointConfig config) { @Override public void onClose(Session session, CloseReason closeReason) { LOGGER.trace("Session closed for client {} with reason {}", id, closeReason); - messages.add("CLOSED: " + closeReason.toString()); + messages.offer("CLOSED: " + closeReason.toString()); session.removeMessageHandler(this); this.session = null; } @@ -85,13 +85,13 @@ public void onClose(Session session, CloseReason closeReason) { @Override public void onError(Session session, Throwable throwable) { LOGGER.trace("Got error for client {}", id, throwable); - messages.add("ERROR: " + throwable.getMessage()); + messages.offer("ERROR: " + throwable.getMessage()); } public void onMessage(String msg) { if (msg != null && !msg.isBlank()) { LOGGER.trace("Message received for client {} :: {}", id, msg); - messages.add(msg); + messages.offer(msg); } else { LOGGER.trace("Ignored empty message for client {} :: {}", id, msg); }