Skip to content

Commit 293e4c7

Browse files
author
David Grieve
authored
Make sure Vertx is closed (#290)
* Make sure Vertx is closed * VertxChannel member vertx cannot be a static.
1 parent 27aad2d commit 293e4c7

File tree

3 files changed

+26
-4
lines changed

3 files changed

+26
-4
lines changed

vertx/src/main/java/com/microsoft/gctoolkit/vertx/VertxChannel.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,18 @@
44
import com.microsoft.gctoolkit.vertx.io.JVMEventCodec;
55
import io.vertx.core.Vertx;
66

7+
import java.util.logging.Level;
8+
import java.util.logging.Logger;
9+
710
public class VertxChannel {
811

9-
private Vertx vertx;
12+
protected static final Logger LOGGER = Logger.getLogger(VertxChannel.class.getName());
13+
14+
//
15+
// Note well! This cannot be a static final field.
16+
// UnifiedJavaVirtualMachineConfigurationTest hangs if it is.
17+
//
18+
private final Vertx vertx;
1019

1120
{
1221
//Disable unused Vert.x functionality
@@ -23,4 +32,14 @@ protected Vertx vertx() {
2332
return vertx;
2433
}
2534

35+
public void close() {
36+
vertx().close(result -> {
37+
if (result.succeeded()) {
38+
LOGGER.log(Level.FINE, "Vertx: closed");
39+
} else {
40+
LOGGER.log(Level.FINE, "Vertx: close failed", result.cause());
41+
}
42+
});
43+
}
44+
2645
}

vertx/src/main/java/com/microsoft/gctoolkit/vertx/VertxDataSourceChannel.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,7 @@ public void publish(ChannelName channel, String message) {
3535
}
3636

3737
@Override
38-
public void close() {}
38+
public void close() {
39+
super.close();
40+
}
3941
}

vertx/src/main/java/com/microsoft/gctoolkit/vertx/VertxJVMEventChannel.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
public class VertxJVMEventChannel extends VertxChannel implements JVMEventChannel {
1717

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

2120
public VertxJVMEventChannel() {}
@@ -47,5 +46,7 @@ public void publish(ChannelName channel, JVMEvent message) {
4746
}
4847

4948
@Override
50-
public void close() {}
49+
public void close() {
50+
super.close();
51+
}
5152
}

0 commit comments

Comments
 (0)