Github user jongyoul commented on the pull request:
https://github.com/apache/spark/pull/3741#issuecomment-67921986
@JoshRosen Exactly, yes. Even though JNI Calls the java method,
runAsSparkUser is covered codes only inside braces. The following is a simple
example.
```scala
class SparkHadoopUtilSuite extends FunSuite {
test("runAsSparkUser scope") {
var hadoopUser: HadoopUser = null
SparkHadoopUtil.get.runAsSparkUser{ () =>
hadoopUser = new HadoopUser
Console.println(s"in scope, same thread ${hadoopUser.getUsername}")
new Thread() {
override def run() = Console.println(s"in scope, different thread,
${hadoopUser.getUsername}")
}.run()
}
Console.println(s"out of scope, same thread, ${hadoopUser.getUsername}")
new Thread() {
override def run() = Console.println(s"out of scope, different
thread, ${hadoopUser.getUsername}")
}.run()
}
}
class HadoopUser {
def getUsername: String =
UserGroupInformation.getCurrentUser.getShortUserName
}
```
```bash
jl$ SPARK_USER=testUSER mvn test
SparkHadoopUtilSuite:
2014-12-23 13:50:47.426 java[73906:867795] Unable to load realm info from
SCDynamicStore
in scope, same thread testUSER
in scope, different thread, testUSER
out of scope, same thread, jl
out of scope, different thread, jl
```
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]