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:
parent
a68bcf2856
commit
e4d696d669
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue