You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by ha...@apache.org on 2012/02/29 11:52:22 UTC

svn commit: r1295061 - in /hadoop/common/trunk/hadoop-common-project/hadoop-common: CHANGES.txt src/main/java/org/apache/hadoop/io/Text.java src/test/java/org/apache/hadoop/io/TestText.java

Author: harsh
Date: Wed Feb 29 10:52:22 2012
New Revision: 1295061

URL: http://svn.apache.org/viewvc?rev=1295061&view=rev
Log:
HADOOP-7940. The Text.clear() method does not clear the bytes as intended. Contributed by Csaba Miklos.

Modified:
    hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
    hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/Text.java
    hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestText.java

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt?rev=1295061&r1=1295060&r2=1295061&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt Wed Feb 29 10:52:22 2012
@@ -188,6 +188,8 @@ Release 0.23.3 - UNRELEASED 
 
     HADOOP-8104. Inconsistent Jackson versions (tucu)
 
+    HADOOP-7940. The Text.clear() method does not clear the bytes as intended. (Csaba Miklos via harsh)
+
 Release 0.23.2 - UNRELEASED 
 
   INCOMPATIBLE CHANGES

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/Text.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/Text.java?rev=1295061&r1=1295060&r2=1295061&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/Text.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/io/Text.java Wed Feb 29 10:52:22 2012
@@ -239,6 +239,7 @@ public class Text extends BinaryComparab
    */
   public void clear() {
     length = 0;
+    bytes = EMPTY_BYTES;
   }
 
   /*

Modified: hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestText.java
URL: http://svn.apache.org/viewvc/hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestText.java?rev=1295061&r1=1295060&r2=1295061&view=diff
==============================================================================
--- hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestText.java (original)
+++ hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/io/TestText.java Wed Feb 29 10:52:22 2012
@@ -192,6 +192,16 @@ public class TestText extends TestCase {
     assertTrue(text.find("\u20ac", 5)==11);
   }
 
+  public void testClear() {
+	Text text = new Text();
+	assertEquals("", text.toString());
+	assertEquals(0, text.getBytes().length);
+	text = new Text("abcd\u20acbdcd\u20ac");
+	text.clear();
+	assertEquals("", text.toString());
+	assertEquals(0, text.getBytes().length);
+  }
+
   public void testFindAfterUpdatingContents() throws Exception {
     Text text = new Text("abcd");
     text.set("a".getBytes());