You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2024/04/12 19:10:41 UTC

(brooklyn-server) branch master updated: reconstruct search path when set without catalog item id

This is an automated email from the ASF dual-hosted git repository.

heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git


The following commit(s) were added to refs/heads/master by this push:
     new 95d3ec329c reconstruct search path when set without catalog item id
95d3ec329c is described below

commit 95d3ec329c03abd8f5812256fa00286f149d1989
Author: Alex Heneveld <al...@cloudsoft.io>
AuthorDate: Fri Apr 12 20:10:10 2024 +0100

    reconstruct search path when set without catalog item id
---
 .../apache/brooklyn/core/mgmt/rebind/RebindIteration.java   | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/RebindIteration.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/RebindIteration.java
index a7c06cd2e4..75bab6133b 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/RebindIteration.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/rebind/RebindIteration.java
@@ -927,15 +927,14 @@ public abstract class RebindIteration {
 
     protected CatalogItemIdAndSearchPath findCatalogItemIds(ClassLoader cl, Map<String,
             EntityMementoManifest> entityIdToManifest, EntityMementoManifest entityManifest) {
+        List<String> searchPath = MutableList.copyOf(entityManifest.getCatalogItemIdSearchPath());
 
         if (entityManifest.getCatalogItemId() != null) {
-            return new CatalogItemIdAndSearchPath(entityManifest.getCatalogItemId(),
-                    entityManifest.getCatalogItemIdSearchPath());
+            return new CatalogItemIdAndSearchPath(entityManifest.getCatalogItemId(), searchPath);
         }
 
         if (BrooklynFeatureEnablement.isEnabled(FEATURE_BACKWARDS_COMPATIBILITY_INFER_CATALOG_ITEM_ON_REBIND)) {
             String typeId = null;
-            List<String> searchPath = MutableList.of();
             //First check if any of the parent entities has a catalogItemId set.
             EntityMementoManifest ptr = entityManifest;
             while (ptr != null) {
@@ -975,7 +974,7 @@ public abstract class RebindIteration {
                 RegisteredType t = types.get(ptr.getType(), BrooklynCatalog.DEFAULT_VERSION);
                 if (t != null) {
                     LOG.debug("Inferred catalog item ID " + t.getId() + " for " + entityManifest + " from ancestor " + ptr);
-                    return new CatalogItemIdAndSearchPath(t.getId(), ImmutableList.<String>of());
+                    return new CatalogItemIdAndSearchPath(t.getId(), entityManifest.getCatalogItemIdSearchPath());
                 }
                 if (ptr.getParent() != null) {
                     ptr = entityIdToManifest.get(ptr.getParent());
@@ -987,7 +986,7 @@ public abstract class RebindIteration {
             //As a last resort go through all catalog items trying to load the type and use the first that succeeds.
             //But first check if can be loaded from the default classpath
             if (JavaBrooklynClassLoadingContext.create(managementContext).tryLoadClass(entityManifest.getType()).isPresent()) {
-                return new CatalogItemIdAndSearchPath(null, ImmutableList.<String>of());
+                return new CatalogItemIdAndSearchPath(null, searchPath);
             }
 
             // TODO get to the point when we can deprecate this behaviour!:
@@ -997,11 +996,11 @@ public abstract class RebindIteration {
                 if (canLoadClass) {
                     LOG.warn("Missing catalog item for " + entityManifest.getId() + " (" + entityManifest.getType()
                             + "), inferring as " + item.getId() + " because that is able to load the item");
-                    return new CatalogItemIdAndSearchPath(item.getId(), ImmutableList.<String>of());
+                    return new CatalogItemIdAndSearchPath(item.getId(), searchPath);
                 }
             }
         }
-        return new CatalogItemIdAndSearchPath(null, ImmutableList.<String>of());
+        return new CatalogItemIdAndSearchPath(null, searchPath);
     }
 
     protected static class LoadedClass<T extends BrooklynObject> {