Skip to content

Commit 284029b

Browse files
committed
Use Java 8 compatible way to get pid
1 parent a0ef3a4 commit 284029b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

core/src/main/scala/org/apache/spark/util/Utils.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2289,7 +2289,8 @@ private[spark] object Utils extends Logging with SparkClassUtils {
22892289

22902290
/** Return a heap dump. Used to capture dumps for the web UI */
22912291
def getHeapHistogram(): Array[String] = {
2292-
val pid = String.valueOf(ProcessHandle.current().pid())
2292+
// From Java 9+, we can use 'ProcessHandle.current().pid()'
2293+
val pid = getProcessName().split("@").head
22932294
val builder = new ProcessBuilder("jmap", "-histo:live", pid)
22942295
builder.redirectErrorStream(true)
22952296
val p = builder.start()

0 commit comments

Comments
 (0)