aboutsummaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorHenri Sara <henri.sara@gmail.com>2017-05-26 08:48:40 +0300
committerPekka Hyvönen <pekka@vaadin.com>2017-05-26 08:48:40 +0300
commitef8542679a59832b796af94e93309e2b9b83345d (patch)
treee787934f4e69b93c1feb19419938785e038cb1c7 /server
parent30f21fa290d5bd6f4980f56cb5b4efdf07322541 (diff)
downloadvaadin-framework-ef8542679a59832b796af94e93309e2b9b83345d.tar.gz
vaadin-framework-ef8542679a59832b796af94e93309e2b9b83345d.zip
Make dirty connector handling more deterministic (#9396)
Changes in connector tracking and cleaning (#9305) changed the behavior so that the framework runs beforeClientResponse methods in a non-deterministic and possibly different order than before. This change makes the framework call beforeClientResponse methods in a more deterministic order (parents before children) and checks that the connector tracker knows the connector.
Diffstat (limited to 'server')
-rw-r--r--server/src/main/java/com/vaadin/server/communication/UidlWriter.java27
1 files changed, 21 insertions, 6 deletions
diff --git a/server/src/main/java/com/vaadin/server/communication/UidlWriter.java b/server/src/main/java/com/vaadin/server/communication/UidlWriter.java
index c6c2d77fcb..d27fc3f0ae 100644
--- a/server/src/main/java/com/vaadin/server/communication/UidlWriter.java
+++ b/server/src/main/java/com/vaadin/server/communication/UidlWriter.java
@@ -90,10 +90,9 @@ public class UidlWriter implements Serializable {
while (true) {
ArrayList<ClientConnector> connectorsToProcess = new ArrayList<>();
- for (ClientConnector c : uiConnectorTracker.getDirtyConnectors()) {
- if (!processedConnectors.contains(c)
- && LegacyCommunicationManager
- .isConnectorVisibleToClient(c)) {
+ for (ClientConnector c : uiConnectorTracker
+ .getDirtyVisibleConnectors()) {
+ if (!processedConnectors.contains(c)) {
connectorsToProcess.add(c);
}
}
@@ -102,9 +101,25 @@ public class UidlWriter implements Serializable {
break;
}
+ // process parents before children
+ Collections.sort(connectorsToProcess,
+ Comparator.comparingInt(conn -> {
+ int depth = 0;
+ ClientConnector connector = conn;
+ // this is a very fast operation, even for 100+ levels
+ while (connector.getParent() != null) {
+ ++depth;
+ connector = connector.getParent();
+ }
+ return depth;
+ }));
+
for (ClientConnector connector : connectorsToProcess) {
- boolean initialized = uiConnectorTracker
- .isClientSideInitialized(connector);
+ // call isDirty() to find out if ConnectorTracker knows the
+ // connector
+ boolean initialized = uiConnectorTracker.isDirty(connector)
+ && uiConnectorTracker
+ .isClientSideInitialized(connector);
processedConnectors.add(connector);
try {