summaryrefslogtreecommitdiffstats
path: root/container-disc
diff options
context:
space:
mode:
authorgjoranv <gv@verizonmedia.com>2020-04-02 17:33:44 +0200
committergjoranv <gv@verizonmedia.com>2020-04-02 17:36:18 +0200
commite077b8fdcd63542cf4464d853845d1b95cc2b43b (patch)
treed6f7d6f4ea1dfdbb979ac4f89804d6b7cee1ef02 /container-disc
parent47019081334e7a779eda4d241546e663ed8f87bc (diff)
Ensure that obsolete bundles are uninstalled
.. even when there are no components to deconstruct. This happens for e.g. pure document-api containers when the user bundle(s) only contain searchers.
Diffstat (limited to 'container-disc')
-rw-r--r--container-disc/src/main/java/com/yahoo/container/jdisc/component/Deconstructor.java2
-rw-r--r--container-disc/src/test/java/com/yahoo/container/jdisc/component/DeconstructorTest.java22
2 files changed, 21 insertions, 3 deletions
diff --git a/container-disc/src/main/java/com/yahoo/container/jdisc/component/Deconstructor.java b/container-disc/src/main/java/com/yahoo/container/jdisc/component/Deconstructor.java
index 3a153ec3d8a..6a46e331762 100644
--- a/container-disc/src/main/java/com/yahoo/container/jdisc/component/Deconstructor.java
+++ b/container-disc/src/main/java/com/yahoo/container/jdisc/component/Deconstructor.java
@@ -61,7 +61,7 @@ public class Deconstructor implements ComponentDeconstructor {
((SharedResource) component).release();
}
}
- if (! destructibleComponents.isEmpty())
+ if (! destructibleComponents.isEmpty() || ! bundles.isEmpty())
executor.schedule(new DestructComponentTask(destructibleComponents, bundles),
delay.getSeconds(), TimeUnit.SECONDS);
}
diff --git a/container-disc/src/test/java/com/yahoo/container/jdisc/component/DeconstructorTest.java b/container-disc/src/test/java/com/yahoo/container/jdisc/component/DeconstructorTest.java
index 345f75f7eb6..dfd3bc36645 100644
--- a/container-disc/src/test/java/com/yahoo/container/jdisc/component/DeconstructorTest.java
+++ b/container-disc/src/test/java/com/yahoo/container/jdisc/component/DeconstructorTest.java
@@ -2,14 +2,13 @@
package com.yahoo.container.jdisc.component;
import com.yahoo.component.AbstractComponent;
+import com.yahoo.container.bundle.MockBundle;
import com.yahoo.container.di.componentgraph.Provider;
import com.yahoo.jdisc.ResourceReference;
import com.yahoo.jdisc.SharedResource;
import org.junit.Before;
import org.junit.Test;
-import java.util.Collections;
-
import static java.util.Collections.emptyList;
import static java.util.Collections.singleton;
import static org.junit.Assert.assertTrue;
@@ -51,6 +50,18 @@ public class DeconstructorTest {
assertTrue(sharedResource.released);
}
+ @Test
+ public void bundles_are_uninstalled() throws InterruptedException {
+ var bundle = new UninstallableMockBundle();
+ // Done by executor, so it takes some time even with a 0 delay.
+ deconstructor.deconstruct(emptyList(), singleton(bundle));
+ int cnt = 0;
+ while (! bundle.uninstalled && (cnt++ < 12000)) {
+ Thread.sleep(10);
+ }
+ assertTrue(bundle.uninstalled);
+ }
+
private static class TestAbstractComponent extends AbstractComponent {
boolean destructed = false;
@Override public void deconstruct() { destructed = true; }
@@ -69,4 +80,11 @@ public class DeconstructorTest {
@Override public ResourceReference refer() { return null; }
@Override public void release() { released = true; }
}
+
+ private static class UninstallableMockBundle extends MockBundle {
+ boolean uninstalled = false;
+ @Override public void uninstall() {
+ uninstalled = true;
+ }
+ }
}