You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by gr...@apache.org on 2014/12/03 17:50:18 UTC

[2/3] incubator-brooklyn git commit: Make BUCKETS map immutable (see review comment from @aledsage)

Make BUCKETS map immutable (see review comment from @aledsage)


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/e4174684
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/e4174684
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/e4174684

Branch: refs/heads/master
Commit: e4174684c40f8311828e50b9adc1f7df23bde951
Parents: edfe121
Author: Andrew Kennedy <gr...@apache.org>
Authored: Wed Dec 3 16:49:12 2014 +0100
Committer: Andrew Kennedy <gr...@apache.org>
Committed: Wed Dec 3 16:49:12 2014 +0100

----------------------------------------------------------------------
 .../java/brooklyn/entity/group/DynamicMultiGroupImpl.java     | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/e4174684/core/src/main/java/brooklyn/entity/group/DynamicMultiGroupImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/group/DynamicMultiGroupImpl.java b/core/src/main/java/brooklyn/entity/group/DynamicMultiGroupImpl.java
index b5d9039..50b9a63 100644
--- a/core/src/main/java/brooklyn/entity/group/DynamicMultiGroupImpl.java
+++ b/core/src/main/java/brooklyn/entity/group/DynamicMultiGroupImpl.java
@@ -39,6 +39,7 @@ import brooklyn.util.collections.MutableMap;
 import com.google.common.base.Function;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Predicates;
+import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.ImmutableSet;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Multimap;
@@ -93,7 +94,7 @@ public class DynamicMultiGroupImpl extends DynamicGroupImpl implements DynamicMu
     @Override
     public void init() {
         super.init();
-        setAttribute(BUCKETS, MutableMap.<String, BasicGroup>of());
+        setAttribute(BUCKETS, ImmutableMap.<String, BasicGroup>of());
         connectScanner();
     }
 
@@ -171,7 +172,7 @@ public class DynamicMultiGroupImpl extends DynamicGroupImpl implements DynamicMu
             Function<Entity, String> bucketFunction = getConfig(BUCKET_FUNCTION);
             EntitySpec<? extends BasicGroup> bucketSpec = getConfig(BUCKET_SPEC);
             if (bucketFunction == null || bucketSpec == null) return;
-            Map<String, BasicGroup> buckets = getAttribute(BUCKETS);
+            Map<String, BasicGroup> buckets = MutableMap.copyOf(getAttribute(BUCKETS));
 
             // Bucketize the members where the function gives a non-null bucket
             Multimap<String, Entity> entityMapping = Multimaps.index(
@@ -197,7 +198,7 @@ public class DynamicMultiGroupImpl extends DynamicGroupImpl implements DynamicMu
             }
 
             // Save the bucket mappings
-            setAttribute(BUCKETS, buckets);
+            setAttribute(BUCKETS, ImmutableMap.copyOf(buckets));
         }
     }