From 88861bc2c371b750d76cdd6412f43748c2163cbd Mon Sep 17 00:00:00 2001 From: reshmabidikar Date: Wed, 22 Nov 2023 18:12:54 +0530 Subject: [PATCH] Changes as per review comments - Round 1 --- .../org/killbill/billing/osgi/BundleRegistry.java | 12 ++++++------ .../killbill/billing/osgi/DefaultOSGIService.java | 3 ++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/osgi/src/main/java/org/killbill/billing/osgi/BundleRegistry.java b/osgi/src/main/java/org/killbill/billing/osgi/BundleRegistry.java index 4e3a5a27..172ddef4 100644 --- a/osgi/src/main/java/org/killbill/billing/osgi/BundleRegistry.java +++ b/osgi/src/main/java/org/killbill/billing/osgi/BundleRegistry.java @@ -100,8 +100,8 @@ private void stopAndUninstallBundle(final Bundle bundle, final String pluginName registry.remove(pluginName); } - public void startBundles(final List mandatoryPlugins) { - log.info("List of mandatory plugins: {}",mandatoryPlugins); + public void startBundles(final Iterable mandatoryPlugins) { + log.info("List of mandatory plugins: {}", mandatoryPlugins); final List pluginsStarted = new LinkedList<>(); for (final BundleWithConfig bundleWithConfig : bundleWithConfigs) { final boolean isBundleStarted = fileInstall.startBundle(bundleWithConfig.getBundle()); @@ -116,7 +116,7 @@ public void startBundles(final List mandatoryPlugins) { } - if (!mandatoryPlugins.isEmpty()) { + if (mandatoryPlugins.iterator().hasNext()) { checkIfMandatoryPluginsAreStarted(pluginsStarted, mandatoryPlugins); } else { @@ -125,15 +125,15 @@ public void startBundles(final List mandatoryPlugins) { } - private void checkIfMandatoryPluginsAreStarted(List pluginsStarted, List mandatoryPlugins){ + private void checkIfMandatoryPluginsAreStarted(final List pluginsStarted, final Iterable mandatoryPlugins){ boolean allMandatoryPluginsStarted = true; for (String pluginName: mandatoryPlugins) { if(!pluginsStarted.contains(pluginName)) { - log.error("Mandatory plugin {} not started",pluginName); //TODO_1911 - Exit here? + log.error("Mandatory plugin {} not started", pluginName); //TODO_1911 - Exit here? allMandatoryPluginsStarted = false; } } - if(allMandatoryPluginsStarted) { + if (allMandatoryPluginsStarted) { log.info("All mandatory plugins are started"); } diff --git a/osgi/src/main/java/org/killbill/billing/osgi/DefaultOSGIService.java b/osgi/src/main/java/org/killbill/billing/osgi/DefaultOSGIService.java index 4570e8f9..1f8dd02c 100644 --- a/osgi/src/main/java/org/killbill/billing/osgi/DefaultOSGIService.java +++ b/osgi/src/main/java/org/killbill/billing/osgi/DefaultOSGIService.java @@ -25,6 +25,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Set; import javax.inject.Inject; import javax.inject.Named; @@ -100,7 +101,7 @@ public void initialize() { @LifecycleHandlerType(LifecycleHandlerType.LifecycleLevel.START_PLUGIN) public void start() { final String mandatoryPlugins = osgiConfig.getMandatoryPluginsList(); - final List mandatoryPluginsList = mandatoryPlugins != null && !mandatoryPlugins.isEmpty() ? List.of(mandatoryPlugins.split(",")) : Collections.emptyList(); + final Set mandatoryPluginsList = mandatoryPlugins != null && !mandatoryPlugins.isEmpty() ? Set.of(mandatoryPlugins.split("\\s*,\\s*")) : Collections.emptySet(); // This will call the start() method for the bundles bundleRegistry.startBundles(mandatoryPluginsList); // Tell the plugins all bundles have started