It make JFR Event Streaming asynchronously with try-catch-resources more understandable
Chihiro Ito
chiroito107 at gmail.com
Sun Feb 16 12:29:11 UTC 2020
Hi,
I tried to use JFR Event Streaming asynchronously. When I use it with
try-catch-resource as the following code [1], It doesn't work. However, It
seems normal behavior.
This reason is that RecordingStream is auto closed. I think when it is
called the close method, JFR and JFR Event Streaming should be stoped. But
It is difficult for the user to aware of why it doesn't work.
Why don't we output the log message for the async user as following [2].
What do you think, everyone?
I already implemented this and it seems fine.
[1]
public class JfrEventStreamingInProcessAsync {
public static void main(String[] args) throws Exception {
Configuration config = Configuration.getConfiguration("default");
try (EventStream es = new RecordingStream(config)) {
es.onEvent("jdk.CPULoad", System.out::println);
es.startAsync();
}
TimeUnit.HOURS.sleep(1);
}
}
[2]
JFR Event streaming is running asynchronously, but it has been closed. It
will be terminated immediately.
Regards,
Chihiro
More information about the hotspot-jfr-dev
mailing list