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

Disallow JFR when HSM is enabled #1764

Merged
merged 1 commit into from
Feb 27, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,13 @@ void startJfrLoop() throws JfrRecorderException {
@Override
public final boolean isEnabled() {
final boolean enabled = jfrConfig.isEnabled();
boolean isHighSecurity = defaultAgentConfig.isHighSecurity();
if (!enabled) {
Agent.LOG.log(Level.INFO, "New Relic JFR Monitor is disabled: JFR config has not been enabled in the Java agent.");
} else if (isHighSecurity) {
Agent.LOG.log(Level.INFO, "New Relic JFR Monitor is enabled but High Security mode is also enabled; JFR will not be activated.");
}
return enabled;
return enabled && !isHighSecurity;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,21 @@ public void jfrLoopDoesNotStartWhenIsEnabledIsFalse() throws JfrRecorderExceptio
assertFalse(spyJfr.isEnabled());
verify(spyJfr, times(0)).startJfrLoop();
}

@Test
public void jfrLoopDoesNotStartWhenIsEnabledIsTrueAndHighSecurityIsTrue() throws JfrRecorderException {
JfrService jfrService = new JfrService(jfrConfig, agentConfig);
JfrService spyJfr = spy(jfrService);
when(agentConfig.isHighSecurity()).thenReturn(true);
when(jfrConfig.isEnabled()).thenReturn(true);
when(spyJfr.coreApisExist()).thenReturn(true);

spyJfr.doStart();

assertFalse(spyJfr.isEnabled());
verify(spyJfr, times(0)).startJfrLoop();
}

@Category( IBMJ9IncompatibleTest.class )
@Test
public void jfrLoopDoesStart() {
Expand Down
Loading