Skip to content

Commit

Permalink
[SPARK-51209][CORE][FOLLOWUP] Use user.name system property first a…
Browse files Browse the repository at this point in the history
…s a fallback

### What changes were proposed in this pull request?

This is a follow-up of #49943 to use `user.name` system property first as a fallback.

### Why are the changes needed?

JVM `user.name` is a more reasonable default value.

### Does this PR introduce _any_ user-facing change?

No.

### How was this patch tested?

Manual review.

### Was this patch authored or co-authored using generative AI tooling?

No.

Closes #49949 from dongjoon-hyun/SPARK-51209-2.

Authored-by: Dongjoon Hyun <[email protected]>
Signed-off-by: Dongjoon Hyun <[email protected]>
  • Loading branch information
dongjoon-hyun committed Feb 14, 2025
1 parent 83ee2a0 commit e840255
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/src/main/scala/org/apache/spark/util/Utils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2439,7 +2439,8 @@ private[spark] object Utils

/**
* Returns the current user name. This is the currently logged in user, unless that's been
* overridden by the `SPARK_USER` environment variable. In case of exceptions, returns 'spark'.
* overridden by the `SPARK_USER` environment variable. In case of exceptions, returns the value
* of {@code System.getProperty("user.name", "<unknown>")}.
*/
def getCurrentUserName(): String = {
try {
Expand All @@ -2448,7 +2449,7 @@ private[spark] object Utils
} catch {
// JEP 486: Permanently Disable the Security Manager
case e: UnsupportedOperationException if e.getMessage().contains("getSubject") =>
"spark"
System.getProperty("user.name", "<unknown>")
}
}

Expand Down

0 comments on commit e840255

Please sign in to comment.