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

raboof pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko.git


The following commit(s) were added to refs/heads/main by this push:
     new b197663bab refactor to use StackWalker (#3369)
b197663bab is described below

commit b197663bab281454523941611d07b6b659d043d7
Author: PJ Fanning <[email protected]>
AuthorDate: Sun Jul 19 17:56:44 2026 +0100

    refactor to use StackWalker (#3369)
---
 .../apache/pekko/persistence/CapabilityFlags.scala  | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git 
a/persistence-tck/src/main/scala/org/apache/pekko/persistence/CapabilityFlags.scala
 
b/persistence-tck/src/main/scala/org/apache/pekko/persistence/CapabilityFlags.scala
index a09441740f..3f866e656a 100644
--- 
a/persistence-tck/src/main/scala/org/apache/pekko/persistence/CapabilityFlags.scala
+++ 
b/persistence-tck/src/main/scala/org/apache/pekko/persistence/CapabilityFlags.scala
@@ -14,16 +14,21 @@
 package org.apache.pekko.persistence
 
 import scala.language.implicitConversions
+import scala.jdk.CollectionConverters._
+import scala.util.Try
 
 sealed abstract class CapabilityFlag {
-  private val capturedStack = new Throwable().getStackTrace
-    .filter(_.getMethodName.startsWith("supports"))
-    .find { el =>
-      val clazz = Class.forName(el.getClassName)
-      clazz.getDeclaredMethod(el.getMethodName).getReturnType == 
classOf[CapabilityFlag]
-    }
-    .map { _.getMethodName }
-    .getOrElse("[unknown]")
+  private val capturedStack: String =
+    StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE).walk { 
stream =>
+      stream.iterator().asScala
+        .filter(_.getMethodName.startsWith("supports"))
+        .find { frame =>
+          
Try(frame.getDeclaringClass.getDeclaredMethod(frame.getMethodName).getReturnType)
+            .toOption
+            .contains(classOf[CapabilityFlag])
+        }
+        .map(_.getMethodName)
+    }.getOrElse("[unknown]")
 
   def name: String = capturedStack
   def value: Boolean


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

Reply via email to