avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AVRO-1667) Parser symbol tree flattening is broken for recursive schemas
Date Tue, 01 Mar 2016 17:58:18 GMT

    [ https://issues.apache.org/jira/browse/AVRO-1667?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15174106#comment-15174106
] 

ASF GitHub Bot commented on AVRO-1667:
--------------------------------------

GitHub user zolyfarkas opened a pull request:

    https://github.com/apache/avro/pull/74

    [fix] AVRO-1667

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/zolyfarkas/avro trunk-AVRO-1667

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/avro/pull/74.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #74
    
----
commit 615301895d33e8b0480fe24abc97f46a8fc1549a
Author: Zoltan Farkas <zolyfarkas@yahoo.com>
Date:   2016-02-13T12:58:42Z

    [fix] AVRO-1667

----


> 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<ValidatingGrammarGenerator.LitS,
Symbol>()));
>         validateNonNull(root, new HashSet<Symbol>());
>     }
>     private static void validateNonNull(final Symbol symb, Set<Symbol> 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)

Mime
View raw message