avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r1124127 - in /avro/trunk: CHANGES.txt lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.java lang/java/avro/src/test/java/org/apache/avro/TestReflect.java
Date Wed, 18 May 2011 09:25:18 GMT
Author: cutting
Date: Wed May 18 09:25:18 2011
New Revision: 1124127

URL: http://svn.apache.org/viewvc?rev=1124127&view=rev
Log:
AVRO-809.  Fix reflect for classes that have no package.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/specific/SpecificData.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=1124127&r1=1124126&r2=1124127&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Wed May 18 09:25:18 2011
@@ -28,6 +28,8 @@ Avro 1.5.2 (unreleased)
 
     AVRO-819. C: Fix file reader EOF detection (dcreager)
 
+    AVRO-809. Java: Fix reflect for classes that have no package. (cutting)
+
 Avro 1.5.1 (unreleased)
 
   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=1124127&r1=1124126&r2=1124127&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 Wed
May 18 09:25:18 2011
@@ -101,7 +101,7 @@ public class SpecificData extends Generi
   public String getClassName(Schema schema) {
     String namespace = schema.getNamespace();
     String name = schema.getName();
-    if (namespace == null)
+    if (namespace == null || "".equals(namespace))
       return name;
     String dot = namespace.endsWith("$") ? "" : ".";
     return namespace + dot + name;

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=1124127&r1=1124126&r2=1124127&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 Wed May 18 09:25:18
2011
@@ -352,6 +352,12 @@ public class TestReflect {
     assertEquals(e1, response.getTypes().get(1));
   }
 
+  @Test public void testNoPackage() throws Exception {
+    Class noPackage = Class.forName("NoPackage");
+    Schema s = ReflectData.get().getSchema(noPackage);
+    assertEquals(noPackage.getName(), ReflectData.get().getClassName(s));
+  }
+
   void checkReadWrite(Object object) throws Exception {
     checkReadWrite(object, ReflectData.get().getSchema(object.getClass()));
   }



Mime
View raw message