diff options
-rw-r--r-- | src/com/vaadin/ui/Window.java | 3 | ||||
-rw-r--r-- | tests/server-side/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java | 17 |
2 files changed, 19 insertions, 1 deletions
diff --git a/src/com/vaadin/ui/Window.java b/src/com/vaadin/ui/Window.java index 32415433ad..fce9a30c82 100644 --- a/src/com/vaadin/ui/Window.java +++ b/src/com/vaadin/ui/Window.java @@ -10,6 +10,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Collections; +import java.util.HashSet; import java.util.Iterator; import java.util.LinkedHashSet; import java.util.LinkedList; @@ -1549,7 +1550,7 @@ public class Window extends Panel implements URIHandler, ParameterHandler, * @return Set of child windows. */ public Set<Window> getChildWindows() { - return Collections.unmodifiableSet(subwindows); + return Collections.unmodifiableSet(new HashSet<Window>(subwindows)); } /** diff --git a/tests/server-side/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java b/tests/server-side/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java index 50de91e2af..74859fd8b7 100644 --- a/tests/server-side/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java +++ b/tests/server-side/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java @@ -5,6 +5,8 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import java.util.Set; + import org.junit.Test; import com.vaadin.Application; @@ -80,4 +82,19 @@ public class AddRemoveSubWindow { assertTrue("Window was not removed correctly", removed); assertNull(subWindow.getParent()); } + + @Test + public void testChildWindowsIteratorModification() { + Window mainWindow = new Window(); + mainWindow.addWindow(new Window()); + mainWindow.addWindow(new Window()); + + Set<Window> childWindows = mainWindow.getChildWindows(); + for (Window window : childWindows) { + mainWindow.removeWindow(window); + } + + assertEquals(2, childWindows.size()); + assertEquals(0, mainWindow.getChildWindows().size()); + } } |