You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pekko.apache.org by he...@apache.org on 2026/06/23 05:23:40 UTC
(pekko) 01/01: refactor: use ProcessHandle.current().pid() instead of RuntimeMXBean hack
This is an automated email from the ASF dual-hosted git repository.
He-Pin pushed a commit to branch refactor/process-pid
in repository https://gitbox.apache.org/repos/asf/pekko.git
commit 7ed148a9664fe9a0d87d5287f514a5cfb51081d3
Author: θιΈ£ <he...@alibaba-inc.com>
AuthorDate: Tue Jun 23 13:23:21 2026 +0800
refactor: use ProcessHandle.current().pid() instead of RuntimeMXBean hack
Motivation:
PerfFlamesSupport.scala parses the PID from RuntimeMXBean.getName()
which returns "pid@hostname" β a pre-JDK 9 hack that depends on
an undocumented string format.
Modification:
Replace with ProcessHandle.current().pid() (JDK 9), the official
API for retrieving the current process ID.
Result:
Cleaner, more reliable PID retrieval without string parsing.
Tests:
sbt "multi-node-testkit/compile" β passed
References:
Refs #3136
---
.../scala/org/apache/pekko/remote/testkit/PerfFlamesSupport.scala | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/multi-node-testkit/src/main/scala/org/apache/pekko/remote/testkit/PerfFlamesSupport.scala b/multi-node-testkit/src/main/scala/org/apache/pekko/remote/testkit/PerfFlamesSupport.scala
index 35c3da6f34..1154263c1c 100644
--- a/multi-node-testkit/src/main/scala/org/apache/pekko/remote/testkit/PerfFlamesSupport.scala
+++ b/multi-node-testkit/src/main/scala/org/apache/pekko/remote/testkit/PerfFlamesSupport.scala
@@ -38,9 +38,7 @@ private[pekko] trait PerfFlamesSupport { self: MultiNodeSpec =>
val afterDelay = pekko.pattern.after(delay, system.scheduler)(Future.successful("GO!"))
afterDelay.onComplete { _ =>
- import java.lang.management._
- val name = ManagementFactory.getRuntimeMXBean.getName
- val pid = name.substring(0, name.indexOf('@')).toInt
+ val pid = ProcessHandle.current().pid()
val perfCommand = s"$perfJavaFlamesPath $pid"
println(s"[perf @ $myself($pid)][OUT]: " + perfCommand)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pekko.apache.org
For additional commands, e-mail: commits-help@pekko.apache.org