Github user chtyim commented on a diff in the pull request:
https://github.com/apache/twill/pull/47#discussion_r108826044
--- Diff:
twill-yarn/src/main/java/org/apache/twill/filesystem/FileContextLocationFactory.java
---
@@ -103,16 +138,32 @@ public Location create(URI uri) {
@Override
public Location getHomeLocation() {
+ FileContext fc = getFileContext();
// Fix for TWILL-163. FileContext.getHomeDirectory() uses
System.getProperty("user.name") instead of UGI
return new FileContextLocation(this, fc,
new
Path(fc.getHomeDirectory().getParent(), fc.getUgi().getShortUserName()));
}
/**
- * Returns the {@link FileContext} used by this {@link LocationFactory}.
+ * Returns the {@link FileContext} for the current user based on {@link
UserGroupInformation#getCurrentUser()}.
+ *
+ * @throws IllegalStateException if failed to determine the current user
or fail to create the FileContext.
+ * @throws RuntimeException if failed to get the {@link FileContext}
object for the current user due to exception
*/
public FileContext getFileContext() {
- return fc;
+ try {
+ return
fileContextCache.getUnchecked(UserGroupInformation.getCurrentUser());
+ } catch (IOException e) {
+ throw new IllegalStateException("Failed to get current user
information", e);
+ } catch (UncheckedExecutionException e) {
+ Throwable cause = e.getCause();
+ if (cause instanceof UnsupportedFileSystemException) {
+ String defaultURI =
configuration.get(CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY,
+
CommonConfigurationKeysPublic.FS_DEFAULT_NAME_DEFAULT);
+ throw new IllegalStateException("File system with URI '" +
defaultURI + "' is not supported", cause);
+ }
+ throw new RuntimeException(cause);
--- End diff --
Well, it can be `Exception` or `RuntimeException`. I can add a check to
just throw the cause without wrapping if the type is `RuntimeException`
---
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.
---