summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorAnna Koskinen <Ansku@users.noreply.github.com>2020-07-30 13:01:44 +0300
committerGitHub <noreply@github.com>2020-07-30 13:01:44 +0300
commit9d027171e6507ecab9051456037c7db013d8cb4b (patch)
tree084249990cd71ccf5f99a43338d454390257dfb6 /client
parent17baaf01b7d5b942856f5be8ba21f3c2918b45e5 (diff)
downloadvaadin-framework-9d027171e6507ecab9051456037c7db013d8cb4b.tar.gz
vaadin-framework-9d027171e6507ecab9051456037c7db013d8cb4b.zip
Use queue for resync requests. (#12043)
There might be pending requests in the queue when a resync request is made (e.g. through a theme change). This can cause conflicts if the resync request is handled immediately. Therefore the resync request should also be added to the queue and only get resolved when doSendInvocationsToServer() gets triggered again. Fixes #11954
Diffstat (limited to 'client')
-rw-r--r--client/src/main/java/com/vaadin/client/communication/MessageSender.java20
1 files changed, 13 insertions, 7 deletions
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 cde6657d1a..9a443adb2e 100644
--- a/client/src/main/java/com/vaadin/client/communication/MessageSender.java
+++ b/client/src/main/java/com/vaadin/client/communication/MessageSender.java
@@ -47,6 +47,7 @@ public class MessageSender {
private ApplicationConnection connection;
private boolean hasActiveRequest = false;
+ private boolean resynchronizeRequested = false;
/**
* Counter for the messages send to the server. First sent message has id 0.
@@ -98,7 +99,7 @@ public class MessageSender {
private void doSendInvocationsToServer() {
ServerRpcQueue serverRpcQueue = getServerRpcQueue();
- if (serverRpcQueue.isEmpty()) {
+ if (serverRpcQueue.isEmpty() && !resynchronizeRequested) {
return;
}
@@ -110,7 +111,7 @@ public class MessageSender {
JsonArray reqJson = serverRpcQueue.toJson();
serverRpcQueue.clear();
- if (reqJson.length() == 0) {
+ if (reqJson.length() == 0 && !resynchronizeRequested) {
// Nothing to send, all invocations were filtered out (for
// non-existing connectors)
getLogger().warning(
@@ -124,6 +125,11 @@ public class MessageSender {
Version.getFullVersion());
connection.getConfiguration().setWidgetsetVersionSent();
}
+ if (resynchronizeRequested) {
+ getLogger().info("Resynchronizing from server");
+ extraJson.put(ApplicationConstants.RESYNCHRONIZE_ID, true);
+ resynchronizeRequested = false;
+ }
if (showLoadingIndicator) {
connection.getLoadingIndicator().trigger();
}
@@ -239,7 +245,8 @@ public class MessageSender {
hasActiveRequest = false;
if (connection.isApplicationRunning()) {
- if (getServerRpcQueue().isFlushPending()) {
+ if (getServerRpcQueue().isFlushPending()
+ || resynchronizeRequested) {
sendInvocationsToServer();
}
runPostRequestHooks(connection.getConfiguration().getRootPanelId());
@@ -350,10 +357,9 @@ public class MessageSender {
*/
public void resynchronize() {
getMessageHandler().onResynchronize();
- getLogger().info("Resynchronizing from server");
- JsonObject resyncParam = Json.createObject();
- resyncParam.put(ApplicationConstants.RESYNCHRONIZE_ID, true);
- send(Json.createArray(), resyncParam);
+ getLogger().info("Resynchronize from server requested");
+ resynchronizeRequested = true;
+ sendInvocationsToServer();
}
/**