[
https://issues.apache.org/jira/browse/AVRO-1711?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15265974#comment-15265974
]
Ryan Blue commented on AVRO-1711:
---------------------------------
[~thiru_mg], your patch accidentally added a space on the break line.
Otherwise, +1.
> 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)