hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject svn commit: r1344363 - in /hbase/trunk/hbase-server/src: main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java test/java/org/apache/hadoop/hbase/io/TestHbaseObjectWritable.java
Date Wed, 30 May 2012 17:55:58 GMT
Author: stack
Date: Wed May 30 17:55:58 2012
New Revision: 1344363

URL: http://svn.apache.org/viewvc?rev=1344363&view=rev
Log:
HBASE-6049 Serializing 'List' containing null elements will cause NullPointerException in
HbaseObjectWritable.writeObject()

Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestHbaseObjectWritable.java

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java?rev=1344363&r1=1344362&r2=1344363&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/io/HbaseObjectWritable.java
Wed May 30 17:55:58 2012
@@ -477,8 +477,9 @@ public class HbaseObjectWritable impleme
       int length = list.size();
       out.writeInt(length);
       for (int i = 0; i < length; i++) {
-        writeObject(out, list.get(i),
-                  list.get(i).getClass(), conf);
+        Object elem = list.get(i);
+        writeObject(out, elem,
+                  elem == null ? Writable.class : elem.getClass(), conf);
       }
     } else if (declClass == String.class) {   // String
       Text.writeString(out, (String)instanceObj);

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestHbaseObjectWritable.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestHbaseObjectWritable.java?rev=1344363&r1=1344362&r2=1344363&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestHbaseObjectWritable.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/io/TestHbaseObjectWritable.java
Wed May 30 17:55:58 2012
@@ -198,6 +198,14 @@ public class TestHbaseObjectWritable ext
     obj = doType(conf, list, List.class);
     assertTrue(obj instanceof List);
     Assert.assertArrayEquals(list.toArray(), ((List)obj).toArray() );
+    //List.class with null values
+    List<String> listWithNulls = new ArrayList<String>();
+    listWithNulls.add("hello");
+    listWithNulls.add("world");
+    listWithNulls.add(null);
+    obj = doType(conf, listWithNulls, List.class);
+    assertTrue(obj instanceof List);
+    Assert.assertArrayEquals(listWithNulls.toArray(), ((List)obj).toArray() );
     //ArrayList.class
     ArrayList<String> arr = new ArrayList<String>();
     arr.add("hello");



Mime
View raw message