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:
parent
4b9c956bc5
commit
42a38a4b58
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue