avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r1386807 - in /avro/trunk: CHANGES.txt lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificData.java
Date Mon, 17 Sep 2012 20:16:22 GMT
Author: cutting
Date: Mon Sep 17 20:16:22 2012
New Revision: 1386807

URL: http://svn.apache.org/viewvc?rev=1386807&view=rev
Log:
AVRO-1166. Java: Fix bug in SpecificData.getSchema(Map).  Contributed by George Fletcher.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java
    avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificData.java

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1386807&r1=1386806&r2=1386807&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Mon Sep 17 20:16:22 2012
@@ -77,6 +77,9 @@ Avro 1.7.2 (unreleased)
     AVRO-1160. C: Better error reporting in avrocat.  (Lucas Martin-King
     via dcreager)
 
+    AVRO-1166. Java: Fix bug in SpecificData.getSchema(Map). (George
+    Fletcher via cutting)
+
 Avro 1.7.1 (16 July 2012)
 
   NEW FEATURES

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java?rev=1386807&r1=1386806&r2=1386807&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java (original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java Mon
Sep 17 20:16:22 2012
@@ -189,8 +189,8 @@ public class SpecificData extends Generi
       } else if (Map.class.isAssignableFrom(raw)) {   // map
         java.lang.reflect.Type key = params[0];
         java.lang.reflect.Type value = params[1];
-        if (!(type instanceof Class
-              && CharSequence.class.isAssignableFrom((Class)type)))
+        if (!(key instanceof Class
+              && CharSequence.class.isAssignableFrom((Class)key)))
           throw new AvroTypeException("Map key class not CharSequence: "+key);
         return Schema.createMap(createSchema(value, names));
       } else {

Modified: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificData.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificData.java?rev=1386807&r1=1386806&r2=1386807&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificData.java
(original)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/specific/TestSpecificData.java
Mon Sep 17 20:16:22 2012
@@ -18,6 +18,7 @@
 package org.apache.avro.specific;
 
 import java.util.List;
+import java.util.Map;
 import java.util.ArrayList;
 
 import org.junit.Test;
@@ -46,6 +47,15 @@ public class TestSpecificData {
     new TestRecord().toString();
   }
 
+  private static class X {
+    public Map<String,String> map;
+  }
+
+  @Test
+  public void testGetMapSchema() throws Exception {
+    SpecificData.get().getSchema(X.class.getField("map").getGenericType());
+  }
+
   @Test
   /** Test nesting of specific data within generic. */
   public void testSpecificWithinGeneric() throws Exception {



Mime
View raw message