summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2012-08-08 12:26:55 +0000
committerLeif Åstrand <leif@vaadin.com>2012-08-08 12:26:55 +0000
commit6ead5944ab0a1e4d48b3f502281ac24d43e5ed89 (patch)
tree0372b9ab3d5532f0a49e6a2adf2e507b61644949
parentf303f62b2e966fe8e4f2a220f03c8c6b777212ed (diff)
downloadvaadin-framework-6ead5944ab0a1e4d48b3f502281ac24d43e5ed89.tar.gz
vaadin-framework-6ead5944ab0a1e4d48b3f502281ac24d43e5ed89.zip
Allow removing Window while iterating child window set (#9251)
svn changeset:24115/svn branch:6.8
-rw-r--r--src/com/vaadin/ui/Window.java3
-rw-r--r--tests/server-side/com/vaadin/tests/server/component/window/AddRemoveSubWindow.java17
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());
+ }
}