zhouyifan279 commented on code in PR #6955:
URL: https://github.com/apache/iceberg/pull/6955#discussion_r1125596035
##########
hive-metastore/src/main/java/org/apache/iceberg/hive/HiveHadoopUtil.java:
##########
@@ -30,11 +30,12 @@ public class HiveHadoopUtil {
private HiveHadoopUtil() {}
public static String currentUser() {
+ String username = null;
try {
- return UserGroupInformation.getCurrentUser().getUserName();
+ username = UserGroupInformation.getCurrentUser().getShortUserName();
} catch (IOException e) {
LOG.warn("Failed to get Hadoop user", e);
- return System.getProperty("user.name");
}
+ return username != null ? username : System.getProperty("user.name");
Review Comment:
I made an IOException("Hadoop user is null") thrown to handle the case
`UserGroupInformation#getShortUserName()` returns null.
Now the code should be both more readable and robust.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]