ayushtkn commented on code in PR #3264:
URL: https://github.com/apache/hive/pull/3264#discussion_r868298191
##########
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:
Is the optimisation preventing doing multiple times FileSystem.get() for
same user and FileSystem to prevent multiple `` fs.initialize(uri, conf);``
calls?
In that case even if we call FileSystem.get() multiple times it would do
init only once, from the next time it will return the same FileSystem instance
from the cache.
It is there in the Javadoc as well
```
* If the there is a cached FS instance matching the same URI, it will
* be returned.
```
--
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]