mirror of
https://github.com/jlengrand/vert.x.git
synced 2026-03-10 08:51:19 +00:00
NPE when undeploying several instances of the same verticle that share the same isolationGroup - closes #3074
This commit is contained in:
@@ -418,9 +418,8 @@ public class DeploymentManager {
|
||||
icl = new IsolatingClassLoader(urls.toArray(new URL[urls.size()]), getCurrentClassLoader(),
|
||||
options.getIsolatedClasses());
|
||||
classloaders.put(isolationGroup, icl);
|
||||
} else {
|
||||
icl.refCount++;
|
||||
}
|
||||
icl.refCount += options.getInstances();
|
||||
cl = icl;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class IsolatingClassLoader extends URLClassLoader {
|
||||
public IsolatingClassLoader(URL[] urls, ClassLoader parent, List<String> isolatedClasses) {
|
||||
super(urls, parent);
|
||||
this.isolatedClasses = isolatedClasses;
|
||||
this.refCount = 1;
|
||||
this.refCount = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1161,12 +1161,24 @@ public class DeploymentTest extends VertxTestBase {
|
||||
|
||||
@Test
|
||||
public void testCloseIsolationGroup() throws Exception {
|
||||
testCloseIsolationGroup(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCloseIsolationGroupMultiInstances() throws Exception {
|
||||
testCloseIsolationGroup(3);
|
||||
}
|
||||
|
||||
private void testCloseIsolationGroup(int instances) throws Exception {
|
||||
boolean expectedSuccess = Thread.currentThread().getContextClassLoader() instanceof URLClassLoader;
|
||||
String dir = createClassOutsideClasspath("MyVerticle");
|
||||
List<String> extraClasspath = Arrays.asList(dir);
|
||||
List<String> extraClasspath = Collections.singletonList(dir);
|
||||
Vertx vertx = Vertx.vertx();
|
||||
try {
|
||||
DeploymentOptions options = new DeploymentOptions().setIsolationGroup("somegroup").setExtraClasspath(extraClasspath);
|
||||
DeploymentOptions options = new DeploymentOptions()
|
||||
.setInstances(instances)
|
||||
.setIsolationGroup("somegroup")
|
||||
.setExtraClasspath(extraClasspath);
|
||||
vertx.deployVerticle("java:" + ExtraCPVerticleNotInParentLoader.class.getCanonicalName(), options, onSuccess(id -> {
|
||||
vertx.close(onSuccess(v -> {
|
||||
assertTrue(ExtraCPVerticleNotInParentLoader.cl.isClosed());
|
||||
@@ -1181,6 +1193,7 @@ public class DeploymentTest extends VertxTestBase {
|
||||
ExtraCPVerticleNotInParentLoader.cl = null;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ParentVerticle extends AbstractVerticle {
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user