diff options
author | Leif Åstrand <leif@vaadin.com> | 2014-03-18 14:24:04 +0200 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2014-04-02 15:27:12 +0000 |
commit | 8138be4b0352c5b2409b48ad600941afeed3b20b (patch) | |
tree | c7a1b4929c8d64c5c774a3f5fd03cf0eab8d7467 /server/src/com/vaadin/ui/AbstractSingleComponentContainer.java | |
parent | e1a987f88d624e6099e2ceae4c463506f1a4b52c (diff) | |
download | vaadin-framework-8138be4b0352c5b2409b48ad600941afeed3b20b.tar.gz vaadin-framework-8138be4b0352c5b2409b48ad600941afeed3b20b.zip |
Make removeFromParent throw if the right session is not locked (#13473)
Change-Id: Id5ef40db07404d7cb41b26768d18e757b8cae2b3
Diffstat (limited to 'server/src/com/vaadin/ui/AbstractSingleComponentContainer.java')
-rw-r--r-- | server/src/com/vaadin/ui/AbstractSingleComponentContainer.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/server/src/com/vaadin/ui/AbstractSingleComponentContainer.java b/server/src/com/vaadin/ui/AbstractSingleComponentContainer.java index 8ad0d23351..534f01d4eb 100644 --- a/server/src/com/vaadin/ui/AbstractSingleComponentContainer.java +++ b/server/src/com/vaadin/ui/AbstractSingleComponentContainer.java @@ -19,6 +19,8 @@ import java.util.Collections; import java.util.Iterator; import com.vaadin.server.ComponentSizeValidator; +import com.vaadin.server.VaadinService; +import com.vaadin.server.VaadinSession; /** * Abstract base class for component containers that have only one child @@ -150,6 +152,19 @@ public abstract class AbstractSingleComponentContainer extends // TODO move utility method elsewhere? public static void removeFromParent(Component content) throws IllegalArgumentException { + // Verify the appropriate session is locked + UI parentUI = content.getUI(); + if (parentUI != null) { + VaadinSession parentSession = parentUI.getSession(); + if (parentSession != null && !parentSession.hasLock()) { + String message = "Cannot remove from parent when the session is not locked."; + if (VaadinService.isOtherSessionLocked(parentSession)) { + message += " Furthermore, there is another locked session, indicating that the component might be about to be moved from one session to another."; + } + throw new IllegalStateException(message); + } + } + HasComponents parent = content.getParent(); if (parent instanceof ComponentContainer) { // If the component already has a parent, try to remove it |