From c56681e130e76f8122ef1d08ef3b7f1d36d07956 Mon Sep 17 00:00:00 2001 From: Leif Åstrand Date: Mon, 15 Apr 2013 15:26:54 +0300 Subject: Don't assign PushConnection to UI before it has been connected (#11506) Change-Id: I728c830d6740f77a200ea69925772924e58f45a4 --- server/src/com/vaadin/ui/UI.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'server/src/com/vaadin/ui') diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java index 303dfc234a..1fb7ace9df 100644 --- a/server/src/com/vaadin/ui/UI.java +++ b/server/src/com/vaadin/ui/UI.java @@ -482,6 +482,8 @@ public abstract class UI extends AbstractSingleComponentContainer implements private PushConnection pushConnection = null; + private boolean hasPendingPush = false; + /** * This method is used by Component.Focusable objects to request focus to * themselves. Focus renders must be handled at window level (instead of @@ -1149,6 +1151,7 @@ public abstract class UI extends AbstractSingleComponentContainer implements public void push() { VaadinSession session = getSession(); if (session != null) { + assert session.hasLock(); if (!getConnectorTracker().hasDirtyConnectors()) { // Do not push if there is nothing to push return; @@ -1157,8 +1160,12 @@ public abstract class UI extends AbstractSingleComponentContainer implements if (session.getPushMode() == PushMode.DISABLED) { throw new IllegalStateException("Push not enabled"); } - assert pushConnection != null; - pushConnection.push(); + + if (pushConnection == null) { + hasPendingPush = true; + } else { + pushConnection.push(); + } } else { throw new UIDetachedException("Trying to push a detached UI"); } @@ -1180,6 +1187,10 @@ public abstract class UI extends AbstractSingleComponentContainer implements assert pushConnection == null; assert connection != null; pushConnection = connection; + if (hasPendingPush) { + hasPendingPush = false; + pushConnection.push(); + } } /** -- cgit v1.2.3