hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject svn commit: r1462676 - in /hbase/branches/0.94/src: main/java/org/apache/hadoop/hbase/security/User.java test/java/org/apache/hadoop/hbase/security/TestUser.java
Date Fri, 29 Mar 2013 23:33:40 GMT
Author: tedyu
Date: Fri Mar 29 23:33:40 2013
New Revision: 1462676

URL: http://svn.apache.org/r1462676
Log:
HBASE-8222 User class should implement equals() and hashCode()


Modified:
    hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/security/User.java
    hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/security/TestUser.java

Modified: hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/security/User.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/security/User.java?rev=1462676&r1=1462675&r2=1462676&view=diff
==============================================================================
--- hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/security/User.java (original)
+++ hbase/branches/0.94/src/main/java/org/apache/hadoop/hbase/security/User.java Fri Mar 29
23:33:40 2013
@@ -127,6 +127,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();
   }

Modified: hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/security/TestUser.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/security/TestUser.java?rev=1462676&r1=1462675&r2=1462676&view=diff
==============================================================================
--- hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/security/TestUser.java (original)
+++ hbase/branches/0.94/src/test/java/org/apache/hadoop/hbase/security/TestUser.java Fri Mar
29 23:33:40 2013
@@ -102,6 +102,8 @@ public class TestUser {
       User u = User.getCurrent();
       assertNotNull(u);
       assertEquals(user1.getName(), u.getName());
+      assertEquals(user1, u);
+      assertEquals(user1.hashCode(), u.hashCode());
     }
   }
 



Mime
View raw message