ramesh0201 commented on code in PR #3264:
URL: https://github.com/apache/hive/pull/3264#discussion_r868232401
##########
common/src/java/org/apache/hadoop/hive/common/FileUtils.java:
##########
@@ -408,10 +408,23 @@ public static FileStatus
getPathOrParentThatExists(FileSystem fs, Path path) thr
return getPathOrParentThatExists(fs, parentPath);
}
- public static void checkFileAccessWithImpersonation(final FileSystem fs,
final FileStatus stat,
- final FsAction action, final String user)
- throws IOException, AccessControlException, InterruptedException,
Exception {
- checkFileAccessWithImpersonation(fs, stat, action, user, null);
+ public static void checkFileAccessWithImpersonation(final FileSystem fs,
final FileStatus stat, final FsAction action,
+ final String user) throws IOException, AccessControlException,
InterruptedException, Exception {
+ UserGroupInformation ugi = Utils.getUGI();
+ String currentUser = ugi.getShortUserName();
+ UserGroupInformation proxyUser = null;
+ FileSystem fsAsUser = null;
+ try {
+ if (user != null && !user.equals(currentUser)) {
+ proxyUser = UserGroupInformation.createProxyUser(user,
UserGroupInformation.getLoginUser());
+ fsAsUser = FileUtils.getFsAsUser(fs, proxyUser);
+ }
+ checkFileAccessWithImpersonation(fs, stat, action, user, null, fsAsUser);
Review Comment:
Moving the FIleSystem.getFsAsUser() outside checkFileAccessWithImpersonation
is the optimization. Just initializing once for the fs and proxyUser.
--
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]