Github user albertshau commented on a diff in the pull request: https://github.com/apache/twill/pull/47#discussion_r108811273 --- 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 -- at this point the cause should be a RuntimeException right? in which case we should just propagate it directly rather than wrapping it.
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. ---