avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r1087137 - in /avro/branches/branch-1.5: ./ lang/java/avro/src/main/java/org/apache/avro/reflect/ lang/java/avro/src/test/java/org/apache/avro/
Date Wed, 30 Mar 2011 23:37:35 GMT
Author: cutting
Date: Wed Mar 30 23:37:35 2011
New Revision: 1087137

URL: http://svn.apache.org/viewvc?rev=1087137&view=rev
Log:
Merge -c 1087136 from trunk to 1.5 branch.  Fixes: AVRO-780.

Modified:
    avro/branches/branch-1.5/   (props changed)
    avro/branches/branch-1.5/CHANGES.txt
    avro/branches/branch-1.5/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java
    avro/branches/branch-1.5/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectDatumWriter.java
    avro/branches/branch-1.5/lang/java/avro/src/test/java/org/apache/avro/TestReflect.java

Propchange: avro/branches/branch-1.5/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Mar 30 23:37:35 2011
@@ -1 +1 @@
-/avro/trunk:1075938,1075993,1078917,1079055,1079060,1079063,1083246,1085921,1086727,1086730,1086866,1087076,1087129
+/avro/trunk:1075938,1075993,1078917,1079055,1079060,1079063,1083246,1085921,1086727,1086730,1086866,1087076,1087129,1087136

Modified: avro/branches/branch-1.5/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.5/CHANGES.txt?rev=1087137&r1=1087136&r2=1087137&view=diff
==============================================================================
--- avro/branches/branch-1.5/CHANGES.txt (original)
+++ avro/branches/branch-1.5/CHANGES.txt Wed Mar 30 23:37:35 2011
@@ -19,6 +19,9 @@ Avro 1.5.1 (unreleased)
 
     AVRO-786. Java: Fix equals() to work on objects containing maps. (cutting)
 
+    AVRO-780. Java: Fix a NullPointerException with reflect data when
+    a union contains an array and null. (cutting)
+
 Avro 1.5.0 (10 March 2011)
 
   INCOMPATIBLE CHANGES

Modified: avro/branches/branch-1.5/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.5/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java?rev=1087137&r1=1087136&r2=1087137&view=diff
==============================================================================
--- avro/branches/branch-1.5/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java
(original)
+++ avro/branches/branch-1.5/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java
Wed Mar 30 23:37:35 2011
@@ -106,6 +106,7 @@ public class ReflectData extends Specifi
 
   @Override
   protected boolean isArray(Object datum) {
+    if (datum == null) return false;
     return (datum instanceof Collection) || datum.getClass().isArray();
   }
 

Modified: avro/branches/branch-1.5/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectDatumWriter.java
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.5/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectDatumWriter.java?rev=1087137&r1=1087136&r2=1087137&view=diff
==============================================================================
--- avro/branches/branch-1.5/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectDatumWriter.java
(original)
+++ avro/branches/branch-1.5/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectDatumWriter.java
Wed Mar 30 23:37:35 2011
@@ -103,7 +103,7 @@ public class ReflectDatumWriter<T> exten
     } catch (NullPointerException e) {            // improve error message
       NullPointerException result =
         new NullPointerException("in "+schema.getFullName()+" "+e.getMessage());
-      result.initCause(e);
+      result.initCause(e.getCause() == null ? e : e.getCause());
       throw result;
     }
   }

Modified: avro/branches/branch-1.5/lang/java/avro/src/test/java/org/apache/avro/TestReflect.java
URL: http://svn.apache.org/viewvc/avro/branches/branch-1.5/lang/java/avro/src/test/java/org/apache/avro/TestReflect.java?rev=1087137&r1=1087136&r2=1087137&view=diff
==============================================================================
--- avro/branches/branch-1.5/lang/java/avro/src/test/java/org/apache/avro/TestReflect.java
(original)
+++ avro/branches/branch-1.5/lang/java/avro/src/test/java/org/apache/avro/TestReflect.java
Wed Mar 30 23:37:35 2011
@@ -550,6 +550,14 @@ public class TestReflect {
     checkBinary(schema, record);
   }
 
+  /** Test union of null and an array. */
+  @Test
+  public void testNullArray() throws Exception {
+    String json = "[{\"type\":\"array\", \"items\": \"long\"}, \"null\"]";
+    Schema schema = Schema.parse(json);
+    checkBinary(schema, null);
+  }
+
   public static void checkBinary(Schema schema, Object datum)
     throws IOException {
     ReflectDatumWriter<Object> writer = new ReflectDatumWriter<Object>(schema);



Mime
View raw message