HADOOP-10017. Fix NPE in DFSClient#getDelegationToken when doing Distcp from a secured cluster to an insecured cluster. Contributed by Haohui Mai.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1529571 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jing Zhao 2013-10-06 06:15:31 +00:00
parent 8e08046661
commit cb5a51565a
3 changed files with 23 additions and 2 deletions

View File

@ -435,6 +435,9 @@ Release 2.1.2 - UNRELEASED
HADOOP-10003. HarFileSystem.listLocatedStatus() fails. HADOOP-10003. HarFileSystem.listLocatedStatus() fails.
(Jason Dere and suresh via suresh) (Jason Dere and suresh via suresh)
HADOOP-10017. Fix NPE in DFSClient#getDelegationToken when doing Distcp
from a secured cluster to an insecured cluster. (Haohui Mai via jing9)
Release 2.1.1-beta - 2013-09-23 Release 2.1.1-beta - 2013-09-23
INCOMPATIBLE CHANGES INCOMPATIBLE CHANGES

View File

@ -900,10 +900,15 @@ public Token<DelegationTokenIdentifier> getDelegationToken(Text renewer)
assert dtService != null; assert dtService != null;
Token<DelegationTokenIdentifier> token = Token<DelegationTokenIdentifier> token =
namenode.getDelegationToken(renewer); namenode.getDelegationToken(renewer);
token.setService(this.dtService);
LOG.info("Created " + DelegationTokenIdentifier.stringifyToken(token)); if (token != null) {
token.setService(this.dtService);
LOG.info("Created " + DelegationTokenIdentifier.stringifyToken(token));
} else {
LOG.info("Cannot get delegation token from " + renewer);
}
return token; return token;
} }
/** /**

View File

@ -94,6 +94,19 @@ private HdfsConfiguration getTestConfiguration() {
return conf; return conf;
} }
@Test
public void testEmptyDelegationToken() throws IOException {
Configuration conf = getTestConfiguration();
MiniDFSCluster cluster = null;
try {
cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).build();
FileSystem fileSys = cluster.getFileSystem();
fileSys.getDelegationToken("");
} finally {
cluster.shutdown();
}
}
@Test @Test
public void testFileSystemCloseAll() throws Exception { public void testFileSystemCloseAll() throws Exception {
Configuration conf = getTestConfiguration(); Configuration conf = getTestConfiguration();