Quellcode durchsuchen

commit ce2db7ab1e3675a235b98801f838c9e334b28a5c
Author: Luke Lu <llu@yahoo-inc.com>
Date: Mon Sep 27 15:24:17 2010 -0700

Fix metrics tag hash code for null values


git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.20-security-patches@1077727 13f79535-47bb-0310-9956-ffa450edef68

Owen O'Malley vor 14 Jahren
Ursprung
Commit
927027cbd3
1 geänderte Dateien mit 5 neuen und 1 gelöschten Zeilen
  1. 5 1
      src/core/org/apache/hadoop/metrics2/MetricsTag.java

+ 5 - 1
src/core/org/apache/hadoop/metrics2/MetricsTag.java

@@ -78,6 +78,10 @@ public class MetricsTag {
     if (!this.description.equals(other.description())) {
       return false;
     }
+    if (this.value == null || other.value() == null) {
+      if (this.value == null && other.value() == null) return true;
+      return false;
+    }
     if (!this.value.equals(other.value())) {
       return false;
     }
@@ -86,7 +90,7 @@ public class MetricsTag {
 
   @Override
   public int hashCode() {
-    return name.hashCode() ^ value.hashCode();
+    return name.hashCode() ^ (value == null ? 0 : value.hashCode());
   }
 
   @Override