[Bug][FsBroker] NPE throw when username is empty (#3731)

When using Broker with an empty username, a NPE is thrown, which is
not expected.
This commit is contained in:
Mingyu Chen
2020-06-01 21:03:21 +08:00
committed by GitHub
parent 8e71c0787c
commit ee260d5721

View File

@ -335,7 +335,7 @@ public class FileSystemManager {
conf.set(FS_HDFS_IMPL_DISABLE_CACHE, "true");
FileSystem dfsFileSystem = null;
if (authentication.equals(AUTHENTICATION_SIMPLE) &&
properties.containsKey(USER_NAME_KEY)) {
properties.containsKey(USER_NAME_KEY) && !Strings.isNullOrEmpty(username)) {
// Use the specified 'username' as the login name
UserGroupInformation ugi = UserGroupInformation.createRemoteUser(username);
dfsFileSystem = ugi.doAs(new PrivilegedExceptionAction<FileSystem>() {