Skip to content

Commit 8dbc884

Browse files
committed
Check whether JFR can be dumped and/or stopped using the dedicated argument
1 parent f7e6b4a commit 8dbc884

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

visualvm/jfr/src/org/graalvm/visualvm/jfr/impl/JFRArguments.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,16 @@ public void run() {
9191
if (dumpJFR != null) {
9292
new Finder(dumpJFR, DUMP_LONG_NAME) {
9393
@Override
94-
public void found(Application application) {
95-
boolean stop = stopJFR != null && stopJFR.length == 1 && stopJFR[0].equals(dumpJFR[0]);
96-
JFRSnapshotSupport.takeJfrDump(application, stop, true);
94+
public void found(final Application application) {
95+
VisualVM.getInstance().runTask(new Runnable() {
96+
public void run() {
97+
if (JFRSnapshotSupport.supportsJfrDump(application)) {
98+
boolean stop = stopJFR != null && stopJFR.length == 1 && stopJFR[0].equals(dumpJFR[0]);
99+
if (stop && !JFRSnapshotSupport.supportsJfrStop(application)) stop = false;
100+
JFRSnapshotSupport.takeJfrDump(application, stop, true);
101+
}
102+
}
103+
});
97104
}
98105
}.find();
99106
return;
@@ -102,8 +109,14 @@ public void found(Application application) {
102109
if (stopJFR != null) {
103110
new Finder(stopJFR, STOP_LONG_NAME) {
104111
@Override
105-
public void found(Application application) {
106-
JFRSnapshotSupport.jfrStopRecording(application);
112+
public void found(final Application application) {
113+
VisualVM.getInstance().runTask(new Runnable() {
114+
public void run() {
115+
if (JFRSnapshotSupport.supportsJfrStop(application)) {
116+
JFRSnapshotSupport.jfrStopRecording(application);
117+
}
118+
}
119+
});
107120
}
108121
}.find();
109122
}

0 commit comments

Comments
 (0)