From 85bdc3a013ab320a48e251ee51b2ca6a1156963c Mon Sep 17 00:00:00 2001 From: Andrew Wang Date: Thu, 20 Nov 2014 11:05:42 -0800 Subject: [PATCH] HADOOP-11323. WritableComparator#compare keeps reference to byte array. Contributed by Wilfred Spiegelenburg. (cherry picked from commit eb4045e7652be6ceaf9dfd33e9139d67774b99ab) --- hadoop-common-project/hadoop-common/CHANGES.txt | 3 +++ .../src/main/java/org/apache/hadoop/io/WritableComparator.java | 1 + 2 files changed, 4 insertions(+) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index b8e9ff12194..e6590771a2a 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -36,6 +36,9 @@ Release 2.7.0 - UNRELEASED OPTIMIZATIONS + HADOOP-11323. WritableComparator#compare keeps reference to byte array. + (Wilfred Spiegelenburg via wang) + BUG FIXES HADOOP-11236. NFS: Fix javadoc warning in RpcProgram.java (Abhiraj Butala via harsh) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/WritableComparator.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/WritableComparator.java index b2738ffa803..35c6ef9a52a 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/WritableComparator.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/WritableComparator.java @@ -160,6 +160,7 @@ public class WritableComparator implements RawComparator, Configurable { buffer.reset(b2, s2, l2); // parse key2 key2.readFields(buffer); + buffer.reset(null, 0, 0); // clean up reference } catch (IOException e) { throw new RuntimeException(e); }