HBASE-8222 User class should implement equals() and hashCode()

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1462672 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Zhihong Yu 2013-03-29 23:23:54 +00:00
parent a68bcf2856
commit e4d696d669
2 changed files with 19 additions and 0 deletions

View File

@ -114,6 +114,23 @@ public abstract class User {
public abstract void obtainAuthTokenForJob(JobConf job)
throws IOException, InterruptedException;
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
return ugi.equals(((User) o).ugi);
}
@Override
public int hashCode() {
return ugi.hashCode();
}
@Override
public String toString() {
return ugi.toString();
}

View File

@ -101,6 +101,8 @@ public class TestUser {
User u = User.getCurrent();
assertNotNull(u);
assertEquals(user1.getName(), u.getName());
assertEquals(user1, u);
assertEquals(user1.hashCode(), u.hashCode());
}
}