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
This commit is contained in:
Chris Nauroth 2013-09-26 20:30:14 +00:00
parent 9a361c5821
commit 8f17d64527
3 changed files with 13 additions and 1 deletions

View File

@ -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.

View File

@ -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<Key, ByteBuffer> buffers =

View File

@ -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)