This is an automated email from the ASF dual-hosted git repository.
He-Pin 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 e1e2f2a4b1 refactor: use ProcessHandle.current().pid() instead of
RuntimeMXBean hack (#3152)
e1e2f2a4b1 is described below
commit e1e2f2a4b1cdc74b8460b9bb2b54db2c47be77e8
Author: He-Pin(kerr) <[email protected]>
AuthorDate: Tue Jun 23 17:17:28 2026 +0800
refactor: use ProcessHandle.current().pid() instead of RuntimeMXBean hack
(#3152)
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: [email protected]
For additional commands, e-mail: [email protected]