From 8f17d645273a30f829bf16f22d8a7c6a9710d627 Mon Sep 17 00:00:00 2001 From: Chris Nauroth Date: Thu, 26 Sep 2013 20:30:14 +0000 Subject: [PATCH] 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 --- .../main/java/org/apache/hadoop/io/ByteBufferPool.java | 2 +- .../org/apache/hadoop/io/ElasticByteBufferPool.java | 10 ++++++++++ hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-4949.txt | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/ByteBufferPool.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/ByteBufferPool.java index bb2c978e09..aa5f8731c5 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/ByteBufferPool.java +++ b/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. diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/ElasticByteBufferPool.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/ElasticByteBufferPool.java index f1ea9ff6b5..c4b4491ec3 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/ElasticByteBufferPool.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/ElasticByteBufferPool.java @@ -52,6 +52,16 @@ public int compareTo(Key other) { 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 buffers = diff --git a/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-4949.txt b/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-4949.txt index 51af0b7aa3..cc6737bc97 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/CHANGES-HDFS-4949.txt +++ b/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)