|
@@ -1392,7 +1392,7 @@ public class UserGroupInformation {
|
|
|
* @param token Token to be added
|
|
|
* @return true on successful add of new token
|
|
|
*/
|
|
|
- public synchronized boolean addToken(Token<? extends TokenIdentifier> token) {
|
|
|
+ public boolean addToken(Token<? extends TokenIdentifier> token) {
|
|
|
return (token != null) ? addToken(token.getService(), token) : false;
|
|
|
}
|
|
|
|
|
@@ -1403,10 +1403,11 @@ public class UserGroupInformation {
|
|
|
* @param token Token to be added
|
|
|
* @return true on successful add of new token
|
|
|
*/
|
|
|
- public synchronized boolean addToken(Text alias,
|
|
|
- Token<? extends TokenIdentifier> token) {
|
|
|
- getCredentialsInternal().addToken(alias, token);
|
|
|
- return true;
|
|
|
+ public boolean addToken(Text alias, Token<? extends TokenIdentifier> token) {
|
|
|
+ synchronized (subject) {
|
|
|
+ getCredentialsInternal().addToken(alias, token);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1414,10 +1415,11 @@ public class UserGroupInformation {
|
|
|
*
|
|
|
* @return an unmodifiable collection of tokens associated with user
|
|
|
*/
|
|
|
- public synchronized
|
|
|
- Collection<Token<? extends TokenIdentifier>> getTokens() {
|
|
|
- return Collections.unmodifiableCollection(
|
|
|
- new ArrayList<Token<?>>(getCredentialsInternal().getAllTokens()));
|
|
|
+ public Collection<Token<? extends TokenIdentifier>> getTokens() {
|
|
|
+ synchronized (subject) {
|
|
|
+ return Collections.unmodifiableCollection(
|
|
|
+ new ArrayList<Token<?>>(getCredentialsInternal().getAllTokens()));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -1425,23 +1427,27 @@ public class UserGroupInformation {
|
|
|
*
|
|
|
* @return Credentials of tokens associated with this user
|
|
|
*/
|
|
|
- public synchronized Credentials getCredentials() {
|
|
|
- Credentials creds = new Credentials(getCredentialsInternal());
|
|
|
- Iterator<Token<?>> iter = creds.getAllTokens().iterator();
|
|
|
- while (iter.hasNext()) {
|
|
|
- if (iter.next() instanceof Token.PrivateToken) {
|
|
|
- iter.remove();
|
|
|
+ public Credentials getCredentials() {
|
|
|
+ synchronized (subject) {
|
|
|
+ Credentials creds = new Credentials(getCredentialsInternal());
|
|
|
+ Iterator<Token<?>> iter = creds.getAllTokens().iterator();
|
|
|
+ while (iter.hasNext()) {
|
|
|
+ if (iter.next() instanceof Token.PrivateToken) {
|
|
|
+ iter.remove();
|
|
|
+ }
|
|
|
}
|
|
|
+ return creds;
|
|
|
}
|
|
|
- return creds;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Add the given Credentials to this user.
|
|
|
* @param credentials of tokens and secrets
|
|
|
*/
|
|
|
- public synchronized void addCredentials(Credentials credentials) {
|
|
|
- getCredentialsInternal().addAll(credentials);
|
|
|
+ public void addCredentials(Credentials credentials) {
|
|
|
+ synchronized (subject) {
|
|
|
+ getCredentialsInternal().addAll(credentials);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private synchronized Credentials getCredentialsInternal() {
|