avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r1071083 - in /avro/trunk: CHANGES.txt lang/java/avro/src/main/java/org/apache/avro/Schema.java lang/java/ipc/src/test/java/org/apache/avro/TestSchema.java
Date Tue, 15 Feb 2011 21:49:21 GMT
Author: cutting
Date: Tue Feb 15 21:49:20 2011
New Revision: 1071083

URL: http://svn.apache.org/viewvc?rev=1071083&view=rev
Log:
AVRO-759. Java: Fix NullPointerException when some but not all fields are aliased.  Contributed
by Xiaolu Ye.

Modified:
    avro/trunk/CHANGES.txt
    avro/trunk/lang/java/avro/src/main/java/org/apache/avro/Schema.java
    avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestSchema.java

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1071083&r1=1071082&r2=1071083&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Tue Feb 15 21:49:20 2011
@@ -212,6 +212,9 @@ Avro 1.5.0 (unreleased)
     over stateful connections, permitting interoperability with
     Python and Ruby, which drop the one-way message attribute. (cutting)
 
+    AVRO-759. Java: Fix NullPointerException when some but not all
+    fields are aliased. (Xiaolu Ye via cutting)
+
 Avro 1.4.1 (13 October 2010)
 
   NEW FEATURES

Modified: avro/trunk/lang/java/avro/src/main/java/org/apache/avro/Schema.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/avro/src/main/java/org/apache/avro/Schema.java?rev=1071083&r1=1071082&r2=1071083&view=diff
==============================================================================
--- avro/trunk/lang/java/avro/src/main/java/org/apache/avro/Schema.java (original)
+++ avro/trunk/lang/java/avro/src/main/java/org/apache/avro/Schema.java Tue Feb 15 21:49:20
2011
@@ -1253,7 +1253,10 @@ public abstract class Schema {
     Map<String,String> recordAliases = fieldAliases.get(record);
     if (recordAliases == null)
       return field;
-    return recordAliases.get(field);
+    String alias = recordAliases.get(field);
+    if (alias == null)
+      return field;
+    return alias;
   }
 
   /**

Modified: avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestSchema.java
URL: http://svn.apache.org/viewvc/avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestSchema.java?rev=1071083&r1=1071082&r2=1071083&view=diff
==============================================================================
--- avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestSchema.java (original)
+++ avro/trunk/lang/java/ipc/src/test/java/org/apache/avro/TestSchema.java Tue Feb 15 21:49:20
2011
@@ -482,10 +482,12 @@ public class TestSchema {
 
   @Test
   public void testAliases() throws Exception {
-    String t1 = "{\"type\":\"record\",\"name\":\"a.b\","
-      +"\"fields\":[{\"name\":\"f\",\"type\":\"long\"}]}";
+    String t1 = "{\"type\":\"record\",\"name\":\"a.b\",\"fields\":["
+      +"{\"name\":\"f\",\"type\":\"long\"},"
+      +"{\"name\":\"h\",\"type\":\"int\"}]}";
     String t2 = "{\"type\":\"record\",\"name\":\"x.y\",\"aliases\":[\"a.b\"],"
-      +"\"fields\":[{\"name\":\"g\",\"type\":\"long\",\"aliases\":[\"f\"]}]}";
+      +"\"fields\":[{\"name\":\"g\",\"type\":\"long\",\"aliases\":[\"f\"]},"
+      +"{\"name\":\"h\",\"type\":\"int\"}]}";
     Schema s1 = Schema.parse(t1);
     Schema s2 = Schema.parse(t2);
     Schema s3 = Schema.applyAliases(s1,s2);



Mime
View raw message