avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tomwh...@apache.org
Subject svn commit: r1602095 - in /avro/trunk: CHANGES.txt lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java lang/java/avro/src/test/java/org/apache/avro/reflect/TestReflect.java
Date Thu, 12 Jun 2014 08:55:33 GMT
Author: tomwhite
Date: Thu Jun 12 08:55:33 2014
New Revision: 1602095

URL: http://svn.apache.org/r1602095
Log:
AVRO-1525. Java: ReflectData cannot resolve union with fixed.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java
    avro/trunk/lang/java/avro/src/test/java/org/apache/avro/reflect/TestReflect.java

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1602095&r1=1602094&r2=1602095&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Thu Jun 12 08:55:33 2014
@@ -89,6 +89,8 @@ Trunk (not yet released)
 
     AVRO-1470. Perl: Fix encoding of boolean values. (John Karp via cutting)
 
+    AVRO-1525. Java: ReflectData cannot resolve union with fixed. (tomwhite)
+
 Avro 1.7.6 (15 January 2014)
 
   NEW FEATURES

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java?rev=1602095&r1=1602094&r2=1602095&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java (original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java Thu Jun
12 08:55:33 2014
@@ -164,6 +164,7 @@ public class ReflectData extends Specifi
     if (super.isRecord(datum)) return true;
     if (datum instanceof Collection) return false;
     if (datum instanceof Map) return false;
+    if (datum instanceof GenericFixed) return false;
     return getSchema(datum.getClass()).getType() == Schema.Type.RECORD;
   }
 

Modified: avro/trunk/lang/java/avro/src/test/java/org/apache/avro/reflect/TestReflect.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/test/java/org/apache/avro/reflect/TestReflect.java?rev=1602095&r1=1602094&r2=1602095&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/test/java/org/apache/avro/reflect/TestReflect.java (original)
+++ avro/trunk/lang/java/avro/src/test/java/org/apache/avro/reflect/TestReflect.java Thu Jun
12 08:55:33 2014
@@ -122,6 +122,22 @@ public class TestReflect {
     assertEquals(1, data.resolveUnion(s, new HashMap<String,Float>()));
   }
 
+  @Test public void testUnionWithFixed() {
+    Schema s = new Schema.Parser().parse
+        ("[\"null\", {\"type\":\"fixed\",\"name\":\"f\",\"size\":1}]");
+    Schema f = new Schema.Parser().parse("{\"type\":\"fixed\",\"name\":\"f\",\"size\":1}");
+    GenericData data = ReflectData.get();
+    assertEquals(1, data.resolveUnion(s, new GenericData.Fixed(f)));
+  }
+
+  @Test public void testUnionWithEnum() {
+    Schema s = new Schema.Parser().parse
+        ("[\"null\", {\"type\":\"enum\",\"name\":\"E\",\"namespace\":" +
+            "\"org.apache.avro.reflect.TestReflect$\",\"symbols\":[\"A\",\"B\"]}]");
+    GenericData data = ReflectData.get();
+    assertEquals(1, data.resolveUnion(s, E.A));
+  }
+
   @Test public void testUnionWithBytes() {
     Schema s = new Schema.Parser().parse ("[\"null\", \"bytes\"]");
     GenericData data = ReflectData.get();



Mime
View raw message