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

better logging on JFR max depth setting #2063

Merged
merged 2 commits into from
Nov 11, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ protected static int stackDepthFromClient(final String userSpecifiedDepth) {
final int stackDepth = Integer.parseInt(userSpecifiedDepth);

// client specified a value considered safe
if (stackDepth < MAX_STACK_DEPTH) {
if (stackDepth <= MAX_STACK_DEPTH) {
log.info("skip setting JFR.configure stackdepth, using " + userSpecifiedDepth);
return stackDepth;
return -1;
}

// limit how deep a stack depth we'll collect
Expand All @@ -162,6 +162,11 @@ private static void setMaxStackDepth() {
maxFrames = stackDepthFromClient(userSpecifiedStackDepth.get());
}

if (maxFrames < 0) {
// user already specified a max stack depth considered safe, skip setting
return;
}

final String result =
SystemAccess.executeDiagnosticCommand(
"jfrConfigure",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ public void testJFROptionsParser(final String option, final String expected) {
}

@ParameterizedTest
@CsvSource({",256", "foo,256", "512,512", "1025,1024"})
@CsvSource({",256", "foo,256", "512,-1", "1024,-1", "1025,1024"})
public void testStackDepthFromClient(final String input, final int expected) {
assertEquals(expected, ProfilingSystem.stackDepthFromClient(input));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public String executeDiagnosticCommand(
try {
diagnosticCommandMBean = new ObjectName("com.sun.management:type=DiagnosticCommand");
} catch (final MalformedObjectNameException ex) {
log.warn("Error during executeDiagnosticCommand: ", ex);
log.debug("Error during executeDiagnosticCommand: ", ex);
return ex.getMessage();
}
try {
Expand All @@ -62,7 +62,7 @@ public String executeDiagnosticCommand(
.invoke(diagnosticCommandMBean, command, args, sig);
return result != null ? result.toString().trim() : null;
} catch (final Throwable ex) {
log.warn("Error invoking diagnostic command: ", ex);
log.debug("Error invoking diagnostic command: ", ex);
return ex.getMessage();
}
}
Expand All @@ -74,7 +74,7 @@ public List<String> getVMArguments() {
try {
args = runtimeMXBean.getInputArguments();
} catch (final Throwable ex) {
log.warn("Error invoking runtimeMxBean.getInputArguments: ", ex);
log.debug("Error invoking runtimeMxBean.getInputArguments: ", ex);
}
return args;
}
Expand Down