HADOOP-6687. user object in the subject in UGI should be reused in case of a relogin.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@952454 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Boris Shkolnik 2010-06-07 21:50:05 +00:00
parent 4b9c956bc5
commit 42a38a4b58
3 changed files with 21 additions and 0 deletions

View File

@ -70,6 +70,9 @@ Trunk (unreleased changes)
HADOOP-6649. login object in UGI should be inside the subject (jnp via boryas)
HADOOP-6687. user object in the subject in UGI should be reused in case
of a relogin. (jnp via boryas)
Release 0.21.0 - Unreleased
INCOMPATIBLE CHANGES

View File

@ -88,6 +88,10 @@ public class UserGroupInformation {
@Override
public boolean commit() throws LoginException {
// if we already have a user, we are done.
if (!subject.getPrincipals(User.class).isEmpty()) {
return true;
}
Principal user = null;
// if we are using kerberos, try it out
if (useKerberos) {

View File

@ -302,4 +302,18 @@ public class TestUserGroupInformation {
//login1 and login2 must be same instances
Assert.assertTrue(login1 == login2);
}
@Test
public void testLoginModuleCommit() throws Exception {
UserGroupInformation loginUgi = UserGroupInformation.getLoginUser();
User user1 = loginUgi.getSubject().getPrincipals(User.class).iterator()
.next();
LoginContext login = user1.getLogin();
login.logout();
login.login();
User user2 = loginUgi.getSubject().getPrincipals(User.class).iterator()
.next();
// user1 and user2 must be same instances.
Assert.assertTrue(user1 == user2);
}
}