Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure Vertx is closed #290

Merged
merged 2 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But why?

//
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 -> {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am concerned that this is a race condition in cases where there is more than 1 channel setup. I've not seen Censum not shutdown because of this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Run the sample in the gctoolkit repository from the main branch. The app should exit when main exits. It does not. One should not have to explicitly call System.exit().

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();
}
}