diff options
author | gjoranv <gv@verizonmedia.com> | 2022-09-07 00:08:59 +0200 |
---|---|---|
committer | gjoranv <gv@verizonmedia.com> | 2022-09-07 00:10:09 +0200 |
commit | 886ea2944ecc6aecb23acd4a880b1c324d510e8f (patch) | |
tree | 725fc640eb983af20983567d487732313d868d38 /container-core/src/main/java/com/yahoo/container/di | |
parent | d45ce8cf57d1e2911954f93ac6e1fb0340be2f06 (diff) |
Uninstall bundles from a failed generation also when failing to ...
set up the graph, before component construction.
Diffstat (limited to 'container-core/src/main/java/com/yahoo/container/di')
-rw-r--r-- | container-core/src/main/java/com/yahoo/container/di/Container.java | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/di/Container.java b/container-core/src/main/java/com/yahoo/container/di/Container.java index b4a22566eef..c34e393ac02 100644 --- a/container-core/src/main/java/com/yahoo/container/di/Container.java +++ b/container-core/src/main/java/com/yahoo/container/di/Container.java @@ -77,7 +77,8 @@ public class Container { newGraph.reuseNodes(oldGraph); } catch (Throwable t) { log.warning("Failed to set up component graph - uninstalling latest bundles. Bootstrap generation: " + getBootstrapGeneration()); - osgi.completeBundleGeneration(Osgi.GenerationStatus.FAILURE); + Collection<Bundle> newBundlesFromFailedGen = osgi.completeBundleGeneration(Osgi.GenerationStatus.FAILURE); + deconstructComponentsAndBundles(getBootstrapGeneration(), newBundlesFromFailedGen, List.of()); throw t; } try { @@ -180,7 +181,11 @@ public class Container { for (Object component : failedGraph.allConstructedComponentsAndProviders()) { if (!currentComponents.contains(component)) unusedComponents.add(component); } - destructor.deconstruct(failedGraph.generation(), unusedComponents, bundlesFromFailedGraph); + deconstructComponentsAndBundles(failedGraph.generation(), bundlesFromFailedGraph, unusedComponents); + } + + private void deconstructComponentsAndBundles(long generation, Collection<Bundle> bundlesFromFailedGraph, List<Object> unusedComponents) { + destructor.deconstruct(generation, unusedComponents, bundlesFromFailedGraph); } private Runnable createPreviousGraphDeconstructionTask(ComponentGraph oldGraph, @@ -272,7 +277,8 @@ public class Container { public void shutdown(ComponentGraph graph) { shutdownConfigRetriever(); if (graph != null) { - scheduleGraphForDeconstruction(graph); + // As we are shutting down, there is no need to uninstall bundles. + deconstructComponentsAndBundles(graph.generation(), List.of(), graph.allConstructedComponentsAndProviders()); destructor.shutdown(); } } @@ -286,11 +292,6 @@ public class Container { subscriberFactory.reloadActiveSubscribers(generation); } - private void scheduleGraphForDeconstruction(ComponentGraph graph) { - // This is only used for shutdown and cleanup of failed graph, so no need to uninstall any bundles. - destructor.deconstruct(graph.generation(), graph.allConstructedComponentsAndProviders(), List.of()); - } - public static <T extends ConfigInstance> T getConfig(ConfigKey<T> key, Map<ConfigKey<? extends ConfigInstance>, ConfigInstance> configs) { ConfigInstance inst = configs.get(key); |