浏览代码

HDFS-5266. ElasticByteBufferPool#Key does not implement equals. Contributed by Chris Nauroth.

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/HDFS-4949@1526671 13f79535-47bb-0310-9956-ffa450edef68
Chris Nauroth 11 年之前
父节点
当前提交
8f17d64527

+ 1 - 1
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/ByteBufferPool.java

@@ -31,7 +31,7 @@ public interface ByteBufferPool {
    * new buffer.
    *
    * @param direct     Whether the buffer should be direct.
-   * @param minLength  The minimum length the buffer will have.
+   * @param length     The minimum length the buffer will have.
    * @return           A new ByteBuffer.  This ByteBuffer must be direct.
    *                   Its capacity can be less than what was requested, but
    *                   must be at least 1 byte.

+ 10 - 0
hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/ElasticByteBufferPool.java

@@ -52,6 +52,16 @@ public final class ElasticByteBufferPool implements ByteBufferPool {
           compare(insertionTime, other.insertionTime).
           result();
     }
+
+    @Override
+    public boolean equals(Object rhs) {
+      try {
+        Key o = (Key)rhs;
+        return (compareTo(o) == 0);
+      } catch (ClassCastException e) {
+        return false;
+      }
+    }
   }
 
   private final TreeMap<Key, ByteBuffer> buffers =

+ 2 - 0
hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-4949.txt

@@ -64,3 +64,5 @@ HDFS-4949 (Unreleased)
 
     HDFS-5210. Fix some failing unit tests on HDFS-4949 branch.
     (Contributed by Andrew Wang)
+
+    HDFS-5266. ElasticByteBufferPool#Key does not implement equals. (cnauroth)