Return-Path: X-Original-To: apmail-avro-commits-archive@www.apache.org Delivered-To: apmail-avro-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id CD08D110F7 for ; Thu, 12 Jun 2014 08:55:55 +0000 (UTC) Received: (qmail 31943 invoked by uid 500); 12 Jun 2014 08:55:55 -0000 Delivered-To: apmail-avro-commits-archive@avro.apache.org Received: (qmail 31908 invoked by uid 500); 12 Jun 2014 08:55:55 -0000 Mailing-List: contact commits-help@avro.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@avro.apache.org Delivered-To: mailing list commits@avro.apache.org Received: (qmail 31901 invoked by uid 99); 12 Jun 2014 08:55:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Jun 2014 08:55:55 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 12 Jun 2014 08:55:53 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id BF2A123889E1; Thu, 12 Jun 2014 08:55:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@avro.apache.org From: tomwhite@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140612085533.BF2A123889E1@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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())); } + @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();