Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -270,20 +270,28 @@ public static boolean shouldLoginFromKeytab(Configuration conf) {
public static final class SecureHadoopUser extends User {
private String shortName;
private LoadingCache<String, String[]> cache;
/**
* Cache value of this instance's {@link #toString()} value. Computing this value is expensive.
* Assumes the UGI is never updated. See HBASE-27708.
*/
private final String toString;

public SecureHadoopUser() throws IOException {
ugi = UserGroupInformation.getCurrentUser();
this.cache = null;
this.toString = ugi.toString();
}

public SecureHadoopUser(UserGroupInformation ugi) {
this.ugi = ugi;
this.cache = null;
this.toString = ugi.toString();
}

public SecureHadoopUser(UserGroupInformation ugi, LoadingCache<String, String[]> cache) {
this.ugi = ugi;
this.cache = cache;
this.toString = ugi.toString();
}

@Override
Expand Down Expand Up @@ -320,6 +328,11 @@ public <T> T runAs(PrivilegedExceptionAction<T> action)
return ugi.doAs(action);
}

@Override
public String toString() {
return toString;
}

/**
* Create a user for testing.
* @see User#createUserForTesting(org.apache.hadoop.conf.Configuration, String, String[])
Expand Down