You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "dongjoon-hyun (via GitHub)" <gi...@apache.org> on 2023/06/26 01:25:24 UTC
[GitHub] [spark] dongjoon-hyun commented on a diff in pull request #41731: [SPARK-44153][CORE][UI][FOLLOWUP] Use JAVA_HOME and stderr
dongjoon-hyun commented on code in PR #41731:
URL: https://github.com/apache/spark/pull/41731#discussion_r1241364434
##########
core/src/main/scala/org/apache/spark/util/Utils.scala:
##########
@@ -2291,15 +2291,16 @@ private[spark] object Utils extends Logging with SparkClassUtils {
def getHeapHistogram(): Array[String] = {
// From Java 9+, we can use 'ProcessHandle.current().pid()'
val pid = getProcessName().split("@").head
- val builder = new ProcessBuilder("jmap", "-histo:live", pid)
- builder.redirectErrorStream(true)
+ val jmap = System.getProperty("java.home") + "/bin/jmap"
+ val builder = new ProcessBuilder(jmap, "-histo:live", pid)
val p = builder.start()
- val r = new BufferedReader(new InputStreamReader(p.getInputStream()))
val rows = ArrayBuffer.empty[String]
- var line = ""
- while (line != null) {
- if (line.nonEmpty) rows += line
- line = r.readLine()
+ Utils.tryWithResource(new BufferedReader(new InputStreamReader(p.getInputStream()))) { r =>
Review Comment:
@mridulm . I'll make another PR to limit the number of results and to address your comment for readLine parts. In this PR, I just wrapped with `tryWithResource`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org