pan3793 commented on a change in pull request #1973:
URL: https://github.com/apache/incubator-kyuubi/pull/1973#discussion_r815538425



##########
File path: kyuubi-common/src/main/scala/org/apache/kyuubi/Utils.scala
##########
@@ -140,7 +140,9 @@ object Utils extends Logging {
     dir
   }
 
-  def currentUser: String = 
UserGroupInformation.getCurrentUser.getShortUserName
+  def currentUser: String =
+    try UserGroupInformation.getCurrentUser.getShortUserName
+    catch { case _: Exception => sys.props.get("user.name").get }

Review comment:
       Can we introduce a util method `hadoopClassPresent`? We may need this in 
other places.
   
   ```
   private[spark] def hadoopClassPresent: Boolean = {
       try {
         Utils.classForName("org.apache.hadoop.security.UserGroupInformation")
         true
       } catch {
         case _: ClassNotFoundException | _: NoClassDefFoundError => false
       }
     }
   ```
   
   `sys.props.get("user.name").get` => `sys.props("user.name")`
   




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to