Skip to content

Commit d1b4ddc

Browse files
arvindKandpal-ksolvessmiklosovic
authored andcommitted
Fix JMXFeatureTest failure due to disabled AsyncProfiler
patch by Arvind Kandpal; reviewed by Jyothsna Konisa, Stefan Miklosovic for CASSANDRA-21135
1 parent 585f89b commit d1b4ddc

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/java/org/apache/cassandra/service/AsyncProfilerService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,10 @@ public void purge()
368368
@Override
369369
public String status()
370370
{
371+
if (!ASYNC_PROFILER_ENABLED.getBoolean())
372+
{
373+
return "Async Profiler is not enabled. Enable it by setting " + ASYNC_PROFILER_ENABLED.getKey() + " property to true.";
374+
}
371375
return run(new ThrowingFunction<>()
372376
{
373377
@Override

test/unit/org/apache/cassandra/service/AsyncProfilerServiceTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,13 @@ public void testSecondStartNotExecuted()
264264
}
265265

266266
@Test
267-
public void testProfilerDisabledThrowsException()
267+
public void testProfilerDisabledReturnsMessage()
268268
{
269269
try (WithProperties properties = new WithProperties().set(ASYNC_PROFILER_UNSAFE_MODE, true).set(ASYNC_PROFILER_ENABLED, false))
270270
{
271-
assertThatThrownBy(() -> {
272-
AsyncProfilerService profiler = getProfiler(true);
273-
profiler.status();
274-
}).hasMessageContaining("Async Profiler is not enabled. Enable it by setting cassandra.async_profiler.enabled property to true.");
271+
AsyncProfilerService profiler = getProfiler(true);
272+
String status = profiler.status();
273+
assertTrue(status.contains("Async Profiler is not enabled. Enable it by setting " + ASYNC_PROFILER_ENABLED.getKey() + " property to true."));
275274
}
276275
}
277276

0 commit comments

Comments
 (0)