avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF subversion and git services (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AVRO-1711) JsonDecoder.skipChildren skips more than it should.
Date Sun, 08 May 2016 22:28:12 GMT

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

ASF subversion and git services commented on AVRO-1711:
-------------------------------------------------------

Commit 7e10babe3eaad11c90cfed41553fc0c1ff90c16a in avro's branch refs/heads/master from [~rdblue]
[ https://git-wip-us.apache.org/repos/asf?p=avro.git;h=7e10bab ]

AVRO-1711: Java: Fix JsonDecoder#skipChildren skipping extra tokens.

Contributed by Zoltan Farkas and Thiruvalluvan M. G.


> JsonDecoder.skipChildren skips more than it should.
> ---------------------------------------------------
>
>                 Key: AVRO-1711
>                 URL: https://issues.apache.org/jira/browse/AVRO-1711
>             Project: Avro
>          Issue Type: Bug
>    Affects Versions: 1.8.0
>            Reporter: Zoltan Farkas
>            Assignee: Zoltan Farkas
>         Attachments: AVRO-1711.patch
>
>
> JsonDecoder.skipChildren() does not respect Contract, it will point to the next available
token after END_ARRAY and END_OBJECT. It should point to END_ARRAY and END_OBJECT instead
> Here is current implementation:
> {noformat}
>       @Override
>       public JsonParser skipChildren() throws IOException {
>         int level = 0;
>         do {
>           switch(elements.get(pos++).token) {
>           case START_ARRAY:
>           case START_OBJECT:
>             level++;
>             break;
>           case END_ARRAY:
>           case END_OBJECT:
>             level--;
>             break;
>           }
>         } while (level > 0);
>         return this;
>       }
> {noformat}
> Here is the documentation of what the method needs to do:
> {noformat}
>     /**
>      * Method that will skip all child tokens of an array or
>      * object token that the parser currently points to,
>      * iff stream points to 
>      * {@link JsonToken#START_OBJECT} or {@link JsonToken#START_ARRAY}.
>      * If not, it will do nothing.
>      * After skipping, stream will point to <b>matching</b>
>      * {@link JsonToken#END_OBJECT} or {@link JsonToken#END_ARRAY}
>      * (possibly skipping nested pairs of START/END OBJECT/ARRAY tokens
>      * as well as value tokens).
>      * The idea is that after calling this method, application
>      * will call {@link #nextToken} to point to the next
>      * available token, if any.
>      */
> {noformat}
> here is the implementation, fixed:
> {noformat}
>       @Override
>       public JsonParser skipChildren() throws IOException {
>         int level = 0;
>         do {
>           switch(elements.get(pos++).token) {
>           case START_ARRAY:
>           case START_OBJECT:
>             level++;
>             break;
>           case END_ARRAY:
>           case END_OBJECT:
>             level--;
>             break;
>           }
>         } while (level > 0);
>         pos--;
>         return this;
>       }
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message