Skip to content

Commit

Permalink
Make sure Vertx is closed (#290)
Browse files Browse the repository at this point in the history
* Make sure Vertx is closed

* VertxChannel member vertx cannot be a static.
  • Loading branch information
dsgrieve committed Apr 27, 2023
1 parent 27aad2d commit 293e4c7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,18 @@
import com.microsoft.gctoolkit.vertx.io.JVMEventCodec;
import io.vertx.core.Vertx;

import java.util.logging.Level;
import java.util.logging.Logger;

public class VertxChannel {

private Vertx vertx;
protected static final Logger LOGGER = Logger.getLogger(VertxChannel.class.getName());

//
// Note well! This cannot be a static final field.
// UnifiedJavaVirtualMachineConfigurationTest hangs if it is.
//
private final Vertx vertx;

{
//Disable unused Vert.x functionality
Expand All @@ -23,4 +32,14 @@ protected Vertx vertx() {
return vertx;
}

public void close() {
vertx().close(result -> {
if (result.succeeded()) {
LOGGER.log(Level.FINE, "Vertx: closed");
} else {
LOGGER.log(Level.FINE, "Vertx: close failed", result.cause());
}
});
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,7 @@ public void publish(ChannelName channel, String message) {
}

@Override
public void close() {}
public void close() {
super.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

public class VertxJVMEventChannel extends VertxChannel implements JVMEventChannel {

private static final Logger LOGGER = Logger.getLogger(VertxJVMEventChannel.class.getName());
final private DeliveryOptions options = new DeliveryOptions().setCodecName(JVMEventCodec.NAME);

public VertxJVMEventChannel() {}
Expand Down Expand Up @@ -47,5 +46,7 @@ public void publish(ChannelName channel, JVMEvent message) {
}

@Override
public void close() {}
public void close() {
super.close();
}
}

0 comments on commit 293e4c7

Please sign in to comment.