diff options
author | Henri Sara <henri.sara@gmail.com> | 2017-05-30 12:38:31 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-30 12:38:31 +0300 |
commit | 2b9bcc62cfa0ee1d4f5da915190a8f03f076037c (patch) | |
tree | 31edb0ff87fb7353286ee62a3c4371315283b1a7 | |
parent | 3217df4491276f5685da2b48bd46624dc5f097b0 (diff) | |
download | vaadin-framework-2b9bcc62cfa0ee1d4f5da915190a8f03f076037c.tar.gz vaadin-framework-2b9bcc62cfa0ee1d4f5da915190a8f03f076037c.zip |
Make TreeData.getChildren() return value immutable (#9455)
This prevents unsupported modifications such as iterator.remove().
Closes #9446
-rw-r--r-- | server/src/main/java/com/vaadin/data/TreeData.java | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/server/src/main/java/com/vaadin/data/TreeData.java b/server/src/main/java/com/vaadin/data/TreeData.java index 7f6cc095bc..b0bdcde835 100644 --- a/server/src/main/java/com/vaadin/data/TreeData.java +++ b/server/src/main/java/com/vaadin/data/TreeData.java @@ -19,6 +19,7 @@ import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -340,7 +341,7 @@ public class TreeData<T> implements Serializable { /** * Gets the root items of this structure. * - * @return the root items of this structure + * @return an unmodifiable list of root items of this structure */ public List<T> getRootItems() { return getChildren(null); @@ -352,7 +353,7 @@ public class TreeData<T> implements Serializable { * @param item * the item for which to retrieve child items for, null to * retrieve all root items - * @return a list of child items for the given item + * @return an unmodifiable list of child items for the given item * * @throws IllegalArgumentException * if the item does not exist in this structure @@ -362,7 +363,8 @@ public class TreeData<T> implements Serializable { throw new IllegalArgumentException( "Item '" + item + "' not in the hierarchy"); } - return itemToWrapperMap.get(item).getChildren(); + return Collections + .unmodifiableList(itemToWrapperMap.get(item).getChildren()); } /** |