avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r1339865 - 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/TestReflect.java
Date Thu, 17 May 2012 21:17:21 GMT
Author: cutting
Date: Thu May 17 21:17:20 2012
New Revision: 1339865

URL: http://svn.apache.org/viewvc?rev=1339865&view=rev
Log:
AVRO-1056. Java: Fix reflect to correctly handle unions containing maps. Contributed by Kevin
Zhao.

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/TestReflect.java

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1339865&r1=1339864&r2=1339865&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Thu May 17 21:17:20 2012
@@ -68,6 +68,9 @@ Avro 1.7.0 (unreleased)
     AVRO-1046. Java: Fix ReflectDatumReader to be able to read generic
     or specific arrays. (cutting)
 
+    AVRO-1056. Java: Fix reflect to correctly handle unions containing
+    maps.  (Kevin Zhao via cutting)
+
 Avro 1.6.3 (5 March 2012)
 
     AVRO-1077. Missing 'inline' for union set function. (thiru)

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=1339865&r1=1339864&r2=1339865&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 May
17 21:17:20 2012
@@ -113,6 +113,7 @@ public class ReflectData extends Specifi
     if (datum == null) return false;
     if (super.isRecord(datum)) return true;
     if (datum instanceof Collection) return false;
+    if (datum instanceof Map) return false;
     return getSchema(datum.getClass()).getType() == Schema.Type.RECORD;
   }
 

Modified: avro/trunk/lang/java/avro/src/test/java/org/apache/avro/TestReflect.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/test/java/org/apache/avro/TestReflect.java?rev=1339865&r1=1339864&r2=1339865&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/test/java/org/apache/avro/TestReflect.java (original)
+++ avro/trunk/lang/java/avro/src/test/java/org/apache/avro/TestReflect.java Thu May 17 21:17:20
2012
@@ -112,6 +112,13 @@ public class TestReflect {
     assertEquals(1, data.resolveUnion(s, new ArrayList<Float>()));
   }
 
+  @Test public void testUnionWithMap() {
+    Schema s = Schema.parse
+      ("[\"null\", {\"type\":\"map\",\"values\":\"float\"}]");
+    GenericData data = ReflectData.get();
+    assertEquals(1, data.resolveUnion(s, new HashMap<String,Float>()));
+  }
+
   @Test public void testUnionWithBytes() {
     Schema s = Schema.parse ("[\"null\", \"bytes\"]");
     GenericData data = ReflectData.get();



Mime
View raw message