Skip to content

Commit

Permalink
8319072: JFR: Turn off events for JFR.view
Browse files Browse the repository at this point in the history
Reviewed-by: mgronlun
  • Loading branch information
egahlin committed Dec 4, 2023
1 parent d5f59cf commit d2c529c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,15 @@ abstract class AbstractDCmd {
// Remember to keep the two sides in synch.
public abstract Argument[] getArgumentInfos();

// Called by native
protected abstract void execute(ArgumentParser parser) throws DCmdException;


// Called by native
public final String[] execute(String source, String arg, char delimiter) throws DCmdException {
this.source = source;
if (isInteractive()) {
JVM.exclude(Thread.currentThread());
}
try {
boolean log = Logger.shouldLog(LogTag.JFR_DCMD, LogLevel.DEBUG);
if (log) {
Expand All @@ -92,9 +94,19 @@ public final String[] execute(String source, String arg, char delimiter) throws
DCmdException e = new DCmdException(iae.getMessage());
e.addSuppressed(iae);
throw e;
} finally {
if (isInteractive()) {
JVM.include(Thread.currentThread());
}
}
}

// Diagnostic commands that are meant to be used interactively
// should turn off events to avoid noise in the output.
protected boolean isInteractive() {
return false;
}

protected final Output getOutput() {
return output;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ protected void execute(ArgumentParser parser) throws DCmdException {
}
}

@Override
protected final boolean isInteractive() {
return true;
}

private String stripQuotes(String text) {
if (text.startsWith("\"")) {
text = text.substring(1);
Expand Down
5 changes: 5 additions & 0 deletions src/jdk.jfr/share/classes/jdk/jfr/internal/dcmd/DCmdView.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ protected void execute(ArgumentParser parser) throws DCmdException {
}
}

@Override
protected final boolean isInteractive() {
return true;
}

@Override
public String[] printHelp() {
List<String> lines = new ArrayList<>();
Expand Down

1 comment on commit d2c529c

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.