svn merge -c 1569382 FIXES: HADOOP-10346. Deadlock while logging tokens. Contributed by Jason Lowe

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1569385 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason Darrell Lowe 2014-02-18 15:27:46 +00:00
parent 9da50ec5e6
commit d34f27becf
2 changed files with 12 additions and 7 deletions

View File

@ -56,6 +56,8 @@ Release 2.4.0 - UNRELEASED
HADOOP-10249. LdapGroupsMapping should trim ldap password read from file. HADOOP-10249. LdapGroupsMapping should trim ldap password read from file.
(Dilli Armugam via suresh) (Dilli Armugam via suresh)
HADOOP-10346. Deadlock while logging tokens (jlowe)
Release 2.3.1 - UNRELEASED Release 2.3.1 - UNRELEASED
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -105,15 +105,18 @@ public class Token<T extends TokenIdentifier> implements Writable {
return identifier; return identifier;
} }
private static synchronized Class<? extends TokenIdentifier> private static Class<? extends TokenIdentifier>
getClassForIdentifier(Text kind) { getClassForIdentifier(Text kind) {
Class<? extends TokenIdentifier> cls = null;
synchronized (Token.class) {
if (tokenKindMap == null) { if (tokenKindMap == null) {
tokenKindMap = Maps.newHashMap(); tokenKindMap = Maps.newHashMap();
for (TokenIdentifier id : ServiceLoader.load(TokenIdentifier.class)) { for (TokenIdentifier id : ServiceLoader.load(TokenIdentifier.class)) {
tokenKindMap.put(id.getKind(), id.getClass()); tokenKindMap.put(id.getKind(), id.getClass());
} }
} }
Class<? extends TokenIdentifier> cls = tokenKindMap.get(kind); cls = tokenKindMap.get(kind);
}
if (cls == null) { if (cls == null) {
LOG.warn("Cannot find class for token kind " + kind); LOG.warn("Cannot find class for token kind " + kind);
return null; return null;