You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2017/10/27 11:26:12 UTC

[7/9] brooklyn-server git commit: duplicate types in different bundles should be returned by `getAll()`

duplicate types in different bundles should be returned by `getAll()`


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

Branch: refs/heads/master
Commit: 081212f9377eba37531166e8ef3ecda0c0a0e753
Parents: 856c1c9
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Thu Oct 26 01:23:34 2017 +0100
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Thu Oct 26 01:23:34 2017 +0100

----------------------------------------------------------------------
 .../core/typereg/BasicBrooklynTypeRegistry.java       | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/081212f9/core/src/main/java/org/apache/brooklyn/core/typereg/BasicBrooklynTypeRegistry.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/typereg/BasicBrooklynTypeRegistry.java b/core/src/main/java/org/apache/brooklyn/core/typereg/BasicBrooklynTypeRegistry.java
index 663e6a5..46d3400 100644
--- a/core/src/main/java/org/apache/brooklyn/core/typereg/BasicBrooklynTypeRegistry.java
+++ b/core/src/main/java/org/apache/brooklyn/core/typereg/BasicBrooklynTypeRegistry.java
@@ -115,14 +115,17 @@ public class BasicBrooklynTypeRegistry implements BrooklynTypeRegistry {
     @SuppressWarnings("deprecation")
     @Override
     public Iterable<RegisteredType> getMatching(Predicate<? super RegisteredType> filter) {
-        Map<String,RegisteredType> result = MutableMap.of();
+        Set<RegisteredType> result = MutableSet.of();
+        // keep name record also so we can remove legacy items that are superseded
+        Set<String> typeNamesFound = MutableSet.of();
         for (RegisteredType rt: getAllWithoutCatalog(filter)) {
-            result.put(rt.getId(), rt);
+            result.add(rt);
+            typeNamesFound.add(rt.getId());
         }
         for (RegisteredType rt: Iterables.filter(
                 Iterables.transform(mgmt.getCatalog().getCatalogItemsLegacy(), RegisteredTypes.CI_TO_RT), 
                 filter)) {
-            if (!result.containsKey(rt.getId())) {
+            if (!typeNamesFound.contains(rt.getId())) {
                 // TODO ideally never come here, however
                 // legacy cataog currently still used for java-scanned annotations; 
                 // hopefully that will be deprecated and removed in near future
@@ -131,10 +134,11 @@ public class BasicBrooklynTypeRegistry implements BrooklynTypeRegistry {
                 // make TypeRegistry instances instead of CatalogItem, esp if we had YOML to write that plan)
                 
                 //log.warn("Item '"+rt.getId()+"' not in type registry; only found in legacy catalog");
-                result.put(rt.getId(), rt);
+                typeNamesFound.add(rt.getId());
+                result.add(rt);
             }
         }
-        return result.values();
+        return result;
     }
 
     @SuppressWarnings("deprecation")