Skip to content

Commit

Permalink
Don't create a new Vert.x on dev mode restart
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Jul 7, 2020
1 parent a149692 commit 629de0a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,14 @@ public void start() throws Exception {

QuarkusBootstrap.Builder bootstrapBuilder = QuarkusBootstrap.builder()
.setApplicationRoot(appRoots.build())
.setTargetDirectory(context.getDevModeRunnerJarFile().getParentFile().toPath())
.setIsolateDeployment(true)
.setLocalProjectDiscovery(context.isLocalProjectDiscovery())
.addAdditionalDeploymentArchive(path)
.setBaseName(context.getBaseName())
.setMode(context.getMode());
if (context.getDevModeRunnerJarFile() != null) {
bootstrapBuilder.setTargetDirectory(context.getDevModeRunnerJarFile().getParentFile().toPath());
}
if (context.getProjectDir() != null) {
bootstrapBuilder.setProjectRoot(context.getProjectDir().toPath());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public class VertxCoreRecorder {

public Supplier<Vertx> configureVertx(VertxConfiguration config,
LaunchMode launchMode, ShutdownContext shutdown, List<Consumer<VertxOptions>> customizers) {
vertx = new VertxSupplier(config, customizers);
if (launchMode != LaunchMode.DEVELOPMENT) {
vertx = new VertxSupplier(config, customizers);
// we need this to be part of the last shutdown tasks because closing it early (basically before Arc)
// could cause problem to beans that rely on Vert.x and contain shutdown tasks
shutdown.addLastShutdownTask(new Runnable() {
Expand All @@ -63,6 +63,31 @@ public void run() {
destroy();
}
});
} else {
if (vertx == null) {
vertx = new VertxSupplier(config, customizers);
} else if (vertx.v != null) {
tryCleanTccl(vertx.v);
}
shutdown.addLastShutdownTask(new Runnable() {
@Override
public void run() {
CountDownLatch latch = new CountDownLatch(1);
if (vertx.v != null) {
vertx.v.eventBus().close(new Handler<AsyncResult<Void>>() {
@Override
public void handle(AsyncResult<Void> event) {
vertx.v.eventBus().start(new Handler<AsyncResult<Void>>() {
@Override
public void handle(AsyncResult<Void> event) {
latch.countDown();
}
});
}
});
}
}
});
}
return vertx;
}
Expand Down Expand Up @@ -303,7 +328,8 @@ public Supplier<EventLoopGroup> bossSupplier() {
return new Supplier<EventLoopGroup>() {
@Override
public EventLoopGroup get() {
return ((VertxImpl) vertx.get()).getAcceptorEventLoopGroup();
vertx.get();
return ((VertxImpl) vertx.v).getAcceptorEventLoopGroup();
}
};
}
Expand Down

0 comments on commit 629de0a

Please sign in to comment.