Merge -r 1358453:1358454 from trunk to branch. FIXES: HADOOP-8566

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1358455 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Alejandro Abdelnur 2012-07-06 22:29:51 +00:00
parent fbb1760459
commit 5fed0da5b2
3 changed files with 12 additions and 2 deletions

View File

@ -134,6 +134,9 @@ Release 2.0.1-alpha - UNRELEASED
HADOOP-8563. don't package hadoop-pipes examples/bin HADOOP-8563. don't package hadoop-pipes examples/bin
(Colin Patrick McCabe via tgraves) (Colin Patrick McCabe via tgraves)
HADOOP-8566. AvroReflectSerializer.accept(Class) throws a NPE if the class has no
package (primitive types and arrays). (tucu)
BREAKDOWN OF HDFS-3042 SUBTASKS BREAKDOWN OF HDFS-3042 SUBTASKS
HADOOP-8220. ZKFailoverController doesn't handle failure to become active HADOOP-8220. ZKFailoverController doesn't handle failure to become active

View File

@ -59,7 +59,7 @@ public class AvroReflectSerialization extends AvroSerialization<Object>{
getPackages(); getPackages();
} }
return AvroReflectSerializable.class.isAssignableFrom(c) || return AvroReflectSerializable.class.isAssignableFrom(c) ||
packages.contains(c.getPackage().getName()); (c.getPackage() != null && packages.contains(c.getPackage().getName()));
} }
private void getPackages() { private void getPackages() {

View File

@ -21,6 +21,7 @@ package org.apache.hadoop.io.serializer.avro;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.io.serializer.SerializationFactory;
import org.apache.hadoop.io.serializer.SerializationTestUtil; import org.apache.hadoop.io.serializer.SerializationTestUtil;
public class TestAvroSerialization extends TestCase { public class TestAvroSerialization extends TestCase {
@ -43,6 +44,12 @@ public class TestAvroSerialization extends TestCase {
assertEquals(before, after); assertEquals(before, after);
} }
public void testAcceptHandlingPrimitivesAndArrays() throws Exception {
SerializationFactory factory = new SerializationFactory(conf);
assertNull(factory.getSerializer(byte[].class));
assertNull(factory.getSerializer(byte.class));
}
public void testReflectInnerClass() throws Exception { public void testReflectInnerClass() throws Exception {
InnerRecord before = new InnerRecord(); InnerRecord before = new InnerRecord();
before.x = 10; before.x = 10;