diff --git a/flow-client/src/main/java/com/vaadin/client/communication/MessageSender.java b/flow-client/src/main/java/com/vaadin/client/communication/MessageSender.java index 8dc9eb0463c..6e2e3921643 100644 --- a/flow-client/src/main/java/com/vaadin/client/communication/MessageSender.java +++ b/flow-client/src/main/java/com/vaadin/client/communication/MessageSender.java @@ -210,7 +210,7 @@ private JsonObject preparePayload(final JsonArray reqInvocations, * The contents of the request to send */ public void send(final JsonObject payload) { - if (!messageQueue.isEmpty()) { + if (hasQueuedMessages()) { messageQueue.add(payload); return; } @@ -238,6 +238,7 @@ private void sendPayload(final JsonObject payload) { } if (push != null && push.isBidirectional()) { + messageQueue.clear(); // When using bidirectional transport, the payload is not resent // to the server during reconnection attempts. // Keep a copy of the message, so that it could be resent to the @@ -377,7 +378,7 @@ public void setClientToServerMessageId(int nextExpectedId, boolean force) { ApplicationConstants.CLIENT_TO_SERVER_ID) < nextExpectedId) { pushPendingMessage = null; } - if (!messageQueue.isEmpty()) { + if (hasQueuedMessages()) { synchronized (messageQueue) { // If queued message is the expected one. remove from queue // and sen next message if any.