diff options
author | Artur <artur@vaadin.com> | 2017-08-01 10:56:41 +0300 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-08-01 10:56:41 +0300 |
commit | 3766ab61c90885c8657186c4b033667dc2fa25db (patch) | |
tree | f0f05b7fbc55d49fff9bb00eceba0e48adef74da /server | |
parent | 0b28903d785ad7a44e9796823d82302cf44c064b (diff) | |
download | vaadin-framework-3766ab61c90885c8657186c4b033667dc2fa25db.tar.gz vaadin-framework-3766ab61c90885c8657186c4b033667dc2fa25db.zip |
Do full connector tracker cleanup when the session lock is released (#9707) (#9730)
As there is no "request end" call after invoking UI.access() from a background thread,
the connector map was not earlier properly cleaned afterwards. If you toggled visibility of a
component from the background thread, the tracker state became inconsistent.
If this becomes a performance problem, it could probably be optimized to that cleanup
is done in request end and only at the end of access if not inside a request.
Backported from master
Fixes #9693
Diffstat (limited to 'server')
3 files changed, 9 insertions, 24 deletions
diff --git a/server/src/main/java/com/vaadin/server/VaadinService.java b/server/src/main/java/com/vaadin/server/VaadinService.java index 75124aa6ef..e453332f02 100644 --- a/server/src/main/java/com/vaadin/server/VaadinService.java +++ b/server/src/main/java/com/vaadin/server/VaadinService.java @@ -1365,20 +1365,6 @@ public abstract class VaadinService implements Serializable { final long duration = (System.nanoTime() - (Long) request .getAttribute(REQUEST_START_TIME_ATTRIBUTE)) / 1000000; session.setLastRequestDuration(duration); - - // Check that connector tracker is in a consistent state here to - // avoid doing it multiple times for a single request - for (UI ui : session.getUIs()) { - try { - ui.getConnectorTracker().ensureCleanedAndConsistent(); - } catch (AssertionError e) { - getLogger().log(Level.SEVERE, - "Error cleaning ConnectionTracker", e); - } catch (Exception e) { - getLogger().log(Level.SEVERE, - "Error cleaning ConnectionTracker", e); - } - } } finally { session.unlock(); } diff --git a/server/src/main/java/com/vaadin/server/VaadinSession.java b/server/src/main/java/com/vaadin/server/VaadinSession.java index f4ebc06335..7014a5f1f5 100644 --- a/server/src/main/java/com/vaadin/server/VaadinSession.java +++ b/server/src/main/java/com/vaadin/server/VaadinSession.java @@ -1009,6 +1009,11 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable { "Exception while cleaning connector map for ui " + ui.getUIId(), e); + } catch (AssertionError e) { + getLogger().log(Level.SEVERE, + "Exception while cleaning connector map for ui " + + ui.getUIId(), + e); } } } diff --git a/server/src/main/java/com/vaadin/ui/ConnectorTracker.java b/server/src/main/java/com/vaadin/ui/ConnectorTracker.java index 043c1174fb..d2b9b65764 100644 --- a/server/src/main/java/com/vaadin/ui/ConnectorTracker.java +++ b/server/src/main/java/com/vaadin/ui/ConnectorTracker.java @@ -272,17 +272,7 @@ public class ConnectorTracker implements Serializable { } cleanStreamVariables(); - } - /** - * Performs expensive checks to ensure that the connector tracker is cleaned - * properly and in a consistent state. - * <p> - * This should only be called by the framework. - * - * @since - */ - public void ensureCleanedAndConsistent() { // Do this expensive check only with assertions enabled assert isHierarchyComplete() : "The connector hierarchy is corrupted. " + "Check for missing calls to super.setParent(), super.attach() and super.detach() " @@ -315,6 +305,10 @@ public class ConnectorTracker implements Serializable { } else if (!uninitializedConnectors.contains(connector) && !LegacyCommunicationManager .isConnectorVisibleToClient(connector)) { + // Connector was visible to the client but is no longer (e.g. + // setVisible(false) has been called or SelectiveRenderer tells + // it's no longer shown) -> make sure that the full state is + // sent again when/if made visible uninitializedConnectors.add(connector); diffStates.remove(connector); assert isRemovalSentToClient(connector) : "Connector " |