aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/com
diff options
context:
space:
mode:
authorLeif Ã…strand <leif@vaadin.com>2013-07-08 17:23:49 +0300
committerJohannes Dahlström <johannesd@vaadin.com>2013-07-10 10:32:38 +0000
commit20162dbe200111a514ab0849963dcf3eea1a9c83 (patch)
treedeb40c8ef3b6ec2c5f620d1a02658050fbac8dbb /server/src/com
parente4011c6fa4d7a00b718551885339854ceacc0cf0 (diff)
downloadvaadin-framework-20162dbe200111a514ab0849963dcf3eea1a9c83.tar.gz
vaadin-framework-20162dbe200111a514ab0849963dcf3eea1a9c83.zip
Set current instances when calling UI.push from VaadinSession.unlock (#12168)
Change-Id: I27795ab9ae3e3692f508e847936ccaa5a1ebadd4
Diffstat (limited to 'server/src/com')
-rw-r--r--server/src/com/vaadin/server/VaadinSession.java14
-rw-r--r--server/src/com/vaadin/ui/UI.java9
2 files changed, 16 insertions, 7 deletions
diff --git a/server/src/com/vaadin/server/VaadinSession.java b/server/src/com/vaadin/server/VaadinSession.java
index 504788d479..9dedddcc2c 100644
--- a/server/src/com/vaadin/server/VaadinSession.java
+++ b/server/src/com/vaadin/server/VaadinSession.java
@@ -885,9 +885,9 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable {
* Unlocks this session. This method should always be used in a finally
* block after {@link #lock()} to ensure that the lock is always released.
* <p>
- * If {@link #getPushMode() the push mode} is {@link PushMode#AUTOMATIC
- * automatic}, pushes the changes in all UIs in this session to their
- * respective clients.
+ * For UIs in this session that have its push mode set to
+ * {@link PushMode#AUTOMATIC automatic}, pending changes will be pushed to
+ * their respective clients.
*
* @see #lock()
* @see UI#push()
@@ -904,7 +904,13 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable {
for (UI ui : getUIs()) {
if (ui.getPushConfiguration().getPushMode() == PushMode.AUTOMATIC) {
- ui.push();
+ Map<Class<?>, CurrentInstance> oldCurrent = CurrentInstance
+ .setCurrent(ui);
+ try {
+ ui.push();
+ } finally {
+ CurrentInstance.restoreInstances(oldCurrent);
+ }
}
}
}
diff --git a/server/src/com/vaadin/ui/UI.java b/server/src/com/vaadin/ui/UI.java
index 6c9551ea81..403bb31f63 100644
--- a/server/src/com/vaadin/ui/UI.java
+++ b/server/src/com/vaadin/ui/UI.java
@@ -1294,15 +1294,18 @@ public abstract class UI extends AbstractSingleComponentContainer implements
* Pushes the pending changes and client RPC invocations of this UI to the
* client-side.
* <p>
- * As with all UI methods, it is not safe to call push() without holding the
- * {@link VaadinSession#lock() session lock}.
+ * As with all UI methods, the session must be locked when calling this
+ * method. It is also recommended that {@link UI#getCurrent()} is set up to
+ * return this UI since writing the response may invoke logic in any
+ * attached component or extension. The recommended way of fulfilling these
+ * conditions is to use {@link #access(Runnable)}.
*
* @throws IllegalStateException
* if push is disabled.
* @throws UIDetachedException
* if this UI is not attached to a session.
*
- * @see #getPushMode()
+ * @see #getPushConfiguration()
*
* @since 7.1
*/