Return-Path: X-Original-To: apmail-avro-dev-archive@www.apache.org Delivered-To: apmail-avro-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E67E918452 for ; Sat, 13 Feb 2016 13:04:18 +0000 (UTC) Received: (qmail 39299 invoked by uid 500); 13 Feb 2016 13:04:18 -0000 Delivered-To: apmail-avro-dev-archive@avro.apache.org Received: (qmail 39237 invoked by uid 500); 13 Feb 2016 13:04:18 -0000 Mailing-List: contact dev-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 dev@avro.apache.org Received: (qmail 39016 invoked by uid 99); 13 Feb 2016 13:04:18 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 13 Feb 2016 13:04:18 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 1EB402C1F60 for ; Sat, 13 Feb 2016 13:04:18 +0000 (UTC) Date: Sat, 13 Feb 2016 13:04:18 +0000 (UTC) From: "Zoltan Farkas (JIRA)" To: dev@avro.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (AVRO-1667) Parser symbol tree flattening is broken for recursive schemas MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/AVRO-1667?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Zoltan Farkas updated AVRO-1667: -------------------------------- Attachment: (was: avro-1667.patch) > Parser symbol tree flattening is broken for recursive schemas > ------------------------------------------------------------- > > Key: AVRO-1667 > URL: https://issues.apache.org/jira/browse/AVRO-1667 > Project: Avro > Issue Type: Bug > Affects Versions: 1.7.7 > Reporter: Zoltan Farkas > Attachments: avro-1667.patch > > > Here is a unit test to reproduce: > {noformat} > package org.apache.avro.io.parsing; > import java.io.IOException; > import java.util.HashMap; > import java.util.HashSet; > import java.util.Set; > import junit.framework.Assert; > import org.apache.avro.Schema; > import org.junit.Test; > public class SymbolTest { > private static final String SCHEMA = "{\"type\":\"record\",\"name\":\"SampleNode\"," > + "\"namespace\":\"org.spf4j.ssdump2.avro\",\n" + > " \"fields\":[\n" + > " {\"name\":\"count\",\"type\":\"int\",\"default\":0},\n" + > " {\"name\":\"subNodes\",\"type\":\n" + > " {\"type\":\"array\",\"items\":{\n" + > " \"type\":\"record\",\"name\":\"SamplePair\",\n" + > " \"fields\":[\n" + > " {\"name\":\"method\",\"type\":\n" + > " {\"type\":\"record\",\"name\":\"Method\",\n" + > " \"fields\":[\n" + > " {\"name\":\"declaringClass\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},\n" + > " {\"name\":\"methodName\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}}\n" + > " ]}},\n" + > " {\"name\":\"node\",\"type\":\"SampleNode\"}]}}}]}"; > @Test > public void testSomeMethod() throws IOException { > Schema schema = new Schema.Parser().parse(SCHEMA); > Symbol root = Symbol.root(new ResolvingGrammarGenerator() > .generate(schema, schema, new HashMap())); > validateNonNull(root, new HashSet()); > } > private static void validateNonNull(final Symbol symb, Set seen) { > if (seen.contains(symb)) { > return; > } else { > seen.add(symb); > } > if (symb.production != null) { > for (Symbol s : symb.production) { > if (s == null) { > Assert.fail("invalid parsing tree should not contain nulls"); > } > if (s.kind != Symbol.Kind.ROOT) { > validateNonNull(s, seen);; > } > } > } > } > } > {noformat} -- This message was sent by Atlassian JIRA (v6.3.4#6332)