This is an automated email from the ASF dual-hosted git repository. aledsage pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/brooklyn-server.git
commit b6500edf082ccc207a892d0cd2889d3c8935bc6e Author: Paul Campbell <pcampb...@kemitix.net> AuthorDate: Wed Oct 24 10:54:46 2018 +0100 The presence of an OsgiManager is not the concern of CatalogUpgradeScanner CatalogUgradeScanner requires an OsgiManager. Branching for special case is pushed out to the (single) caller, where it is clear that the ManagementContext is being set to an empty set of CatalogUpgrades. --- .../core/catalog/internal/CatalogInitialization.java | 10 ++++++++-- .../core/catalog/internal/CatalogUpgradeScanner.java | 14 ++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java index 9dcaa4b..e284479 100644 --- a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java +++ b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogInitialization.java @@ -254,8 +254,14 @@ public class CatalogInitialization implements ManagementContextInjectable { populateInitialCatalogImpl(true); - final CatalogUpgrades catalogUpgrades = catalogUpgradeScanner.scan(rebindLogger); - CatalogUpgrades.storeInManagementContext(catalogUpgrades, managementContext); + final Maybe<OsgiManager> osgiManager = managementContext.getOsgiManager(); + if (osgiManager.isAbsent()) { + // Can't find any bundles to tell if there are upgrades. Could be running tests; do no filtering. + CatalogUpgrades.storeInManagementContext(CatalogUpgrades.EMPTY, managementContext); + } else { + final CatalogUpgrades catalogUpgrades = catalogUpgradeScanner.scan(osgiManager.get(), rebindLogger); + CatalogUpgrades.storeInManagementContext(catalogUpgrades, managementContext); + } PersistedCatalogState filteredPersistedState = filterBundlesAndCatalogInPersistedState(persistedState, rebindLogger); addPersistedCatalogImpl(filteredPersistedState, exceptionHandler, rebindLogger); diff --git a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogUpgradeScanner.java b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogUpgradeScanner.java index 342e3af..446c083 100644 --- a/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogUpgradeScanner.java +++ b/core/src/main/java/org/apache/brooklyn/core/catalog/internal/CatalogUpgradeScanner.java @@ -42,15 +42,13 @@ class CatalogUpgradeScanner { this.managementContext = managementContext; } - public CatalogUpgrades scan(final CatalogInitialization.RebindLogger rebindLogger) { - Maybe<OsgiManager> osgiManager = managementContext.getOsgiManager(); - if (osgiManager.isAbsent()) { - // Can't find any bundles to tell if there are upgrades. Could be running tests; do no filtering. - return CatalogUpgrades.EMPTY; - } + public CatalogUpgrades scan( + final OsgiManager osgiManager, + final CatalogInitialization.RebindLogger rebindLogger + ) { final CatalogUpgrades.Builder catalogUpgradesBuilder = CatalogUpgrades.builder(); - scanManagedBundles(osgiManager.get(), catalogUpgradesBuilder, rebindLogger); - scanAllBundles(osgiManager.get(), catalogUpgradesBuilder); + scanManagedBundles(osgiManager, catalogUpgradesBuilder, rebindLogger); + scanAllBundles(osgiManager, catalogUpgradesBuilder); return catalogUpgradesBuilder.build(); }