aboutsummaryrefslogtreecommitdiffstats
path: root/client/src
diff options
context:
space:
mode:
authorTatu Lund <tatu@vaadin.com>2019-11-05 16:16:38 +0200
committerGitHub <noreply@github.com>2019-11-05 16:16:38 +0200
commitfd1a8df74a6ddba0c2ff2862ee02f58deebdf6e1 (patch)
treee4a750e5d05979a1961a063cd765f0394b7bec76 /client/src
parent0b627f975ddae79d4d9d1cf4b12e6c31eb31eb7a (diff)
downloadvaadin-framework-fd1a8df74a6ddba0c2ff2862ee02f58deebdf6e1.tar.gz
vaadin-framework-fd1a8df74a6ddba0c2ff2862ee02f58deebdf6e1.zip
Fixing issue with Push stopping working in some circumstances (#11791)
* Fixing issue with Push stopping working in some circumstances If new request is attempted when resynchronization is ongoing, the Push will stop working. This patch fixes the issue by aborting handleJson if resynch is already ongoing. This PR supercedes https://github.com/vaadin/framework/pull/11786 Fixes #11702, #7719 * Call onResynchronize() in MessageHandler * Optimizing
Diffstat (limited to 'client/src')
-rw-r--r--client/src/main/java/com/vaadin/client/communication/MessageHandler.java18
-rw-r--r--client/src/main/java/com/vaadin/client/communication/MessageSender.java1
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 a622bf1614..8e16293423 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.
@@ -258,7 +259,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
@@ -321,7 +332,7 @@ public class MessageHandler {
int serverNextExpected = json
.getInt(ApplicationConstants.CLIENT_TO_SERVER_ID);
getMessageSender().setClientToServerMessageId(serverNextExpected,
- isResynchronize(json));
+ hasResynchronize);
}
if (serverId != -1) {
@@ -1822,4 +1833,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 5864ee5ee7..cde6657d1a 100644
--- a/client/src/main/java/com/vaadin/client/communication/MessageSender.java
+++ b/client/src/main/java/com/vaadin/client/communication/MessageSender.java
@@ -349,6 +349,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);