diff options
author | Tatu Lund <tatu@vaadin.com> | 2019-11-11 15:49:21 +0200 |
---|---|---|
committer | Anna Koskinen <Ansku@users.noreply.github.com> | 2019-11-11 15:49:21 +0200 |
commit | 80146a1a643ee8e111e19136f6cdaf613088137d (patch) | |
tree | dd078462b39f7b9556ff609b872162a5cf9e4a11 | |
parent | 2ad8d3a27fe8ca0f00972ca6220b83d948ef6315 (diff) | |
download | vaadin-framework-80146a1a643ee8e111e19136f6cdaf613088137d.tar.gz vaadin-framework-80146a1a643ee8e111e19136f6cdaf613088137d.zip |
Cherry pick PR #11791 from Vaadin 8 (#11798)
* Cherry pick PR #11791 from Vaadin 8
See: https://github.com/vaadin/framework/pull/11791
-rw-r--r-- | client/src/main/java/com/vaadin/client/communication/MessageHandler.java | 18 | ||||
-rw-r--r-- | client/src/main/java/com/vaadin/client/communication/MessageSender.java | 1 |
2 files changed, 17 insertions, 2 deletions
diff --git a/client/src/main/java/com/vaadin/client/communication/MessageHandler.java b/client/src/main/java/com/vaadin/client/communication/MessageHandler.java index c4e7a0d297..a43cba7de1 100644 --- a/client/src/main/java/com/vaadin/client/communication/MessageHandler.java +++ b/client/src/main/java/com/vaadin/client/communication/MessageHandler.java @@ -193,6 +193,7 @@ public class MessageHandler { private int lastSeenServerSyncId = UNDEFINED_SYNC_ID; private ApplicationConnection connection; + private boolean resyncInProgress; /** * Data structure holding information about pending UIDL messages. @@ -263,7 +264,17 @@ public class MessageHandler { protected void handleJSON(final ValueMap json) { final int serverId = getServerId(json); - if (isResynchronize(json) && !isNextExpectedMessage(serverId)) { + boolean hasResynchronize = isResynchronize(json); + + if (!hasResynchronize && resyncInProgress) { + Logger.getLogger(MessageHandler.class.getName()) + .warning("Dropping the response of a request before a resync request."); + return; + } + + resyncInProgress = false; + + if (hasResynchronize && !isNextExpectedMessage(serverId)) { // Resynchronize request. We must remove any old pending // messages and ensure this is handled next. Otherwise we // would keep waiting for an older message forever (if this @@ -326,7 +337,7 @@ public class MessageHandler { int serverNextExpected = json .getInt(ApplicationConstants.CLIENT_TO_SERVER_ID); getMessageSender().setClientToServerMessageId(serverNextExpected, - isResynchronize(json)); + hasResynchronize); } if (serverId != -1) { @@ -1836,4 +1847,7 @@ public class MessageHandler { } }-*/; + public void onResynchronize() { + resyncInProgress = true; + } } diff --git a/client/src/main/java/com/vaadin/client/communication/MessageSender.java b/client/src/main/java/com/vaadin/client/communication/MessageSender.java index b28efff85e..1c061eb59e 100644 --- a/client/src/main/java/com/vaadin/client/communication/MessageSender.java +++ b/client/src/main/java/com/vaadin/client/communication/MessageSender.java @@ -358,6 +358,7 @@ public class MessageSender { * state from the server */ public void resynchronize() { + getMessageHandler().onResynchronize(); getLogger().info("Resynchronizing from server"); JsonObject resyncParam = Json.createObject(); resyncParam.put(ApplicationConstants.RESYNCHRONIZE_ID, true); |