This is an automated email from the ASF dual-hosted git repository.

smiklosovic pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/trunk by this push:
     new d1b4ddc32a Fix JMXFeatureTest failure due to disabled AsyncProfiler
d1b4ddc32a is described below

commit d1b4ddc32acd8328f83ea7b5dd5a8cd3437ded04
Author: arvindksi274-ksolves <[email protected]>
AuthorDate: Tue Jan 27 11:26:33 2026 +0530

    Fix JMXFeatureTest failure due to disabled AsyncProfiler
    
    patch by Arvind Kandpal; reviewed by Jyothsna Konisa, Stefan Miklosovic for 
CASSANDRA-21135
---
 src/java/org/apache/cassandra/service/AsyncProfilerService.java  | 4 ++++
 .../org/apache/cassandra/service/AsyncProfilerServiceTest.java   | 9 ++++-----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/java/org/apache/cassandra/service/AsyncProfilerService.java 
b/src/java/org/apache/cassandra/service/AsyncProfilerService.java
index f287857e1b..86db64da0a 100644
--- a/src/java/org/apache/cassandra/service/AsyncProfilerService.java
+++ b/src/java/org/apache/cassandra/service/AsyncProfilerService.java
@@ -368,6 +368,10 @@ public class AsyncProfilerService implements 
AsyncProfilerMBean
     @Override
     public String status()
     {
+        if (!ASYNC_PROFILER_ENABLED.getBoolean())
+        {
+             return "Async Profiler is not enabled. Enable it by setting " + 
ASYNC_PROFILER_ENABLED.getKey() + " property to true.";
+        }
         return run(new ThrowingFunction<>()
         {
             @Override
diff --git 
a/test/unit/org/apache/cassandra/service/AsyncProfilerServiceTest.java 
b/test/unit/org/apache/cassandra/service/AsyncProfilerServiceTest.java
index a05b3a6108..ad157fe28c 100644
--- a/test/unit/org/apache/cassandra/service/AsyncProfilerServiceTest.java
+++ b/test/unit/org/apache/cassandra/service/AsyncProfilerServiceTest.java
@@ -264,14 +264,13 @@ public class AsyncProfilerServiceTest
     }
 
     @Test
-    public void testProfilerDisabledThrowsException()
+    public void testProfilerDisabledReturnsMessage()
     {
         try (WithProperties properties = new 
WithProperties().set(ASYNC_PROFILER_UNSAFE_MODE, 
true).set(ASYNC_PROFILER_ENABLED, false))
         {
-            assertThatThrownBy(() -> {
-                AsyncProfilerService profiler = getProfiler(true);
-                profiler.status();
-            }).hasMessageContaining("Async Profiler is not enabled. Enable it 
by setting cassandra.async_profiler.enabled property to true.");
+            AsyncProfilerService profiler = getProfiler(true);
+            String status = profiler.status();
+            assertTrue(status.contains("Async Profiler is not enabled. Enable 
it by setting " + ASYNC_PROFILER_ENABLED.getKey() + " property to true."));
         }
     }
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to