[
https://issues.apache.org/jira/browse/AVRO-530?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13465525#comment-13465525
]
Cristian Opris commented on AVRO-530:
-------------------------------------
Is this supposed to work atm at the json schema representation level ? The
following simple example results in StackOverflow even if there are comments in
the Symbol class that it's supposed to handle recursive symbols:
Code is in scala repl:
{code}
val recType = new Schema.Parser().parse(""" {"type":"record",
"name":"SelfRefType", "fields":[{"type": "SelfRefType", "name":"self"}]} """)
recType: org.apache.avro.Schema =
{"type":"record","name":"SelfRefType","fields":[{"name":"self","type":"SelfRefType"}]}
val encoder = EncoderFactory.get().jsonEncoder(recType, Console.out)
java.lang.StackOverflowError
at org.apache.avro.io.parsing.Symbol.flattenedSize(Symbol.java:213)
at
org.apache.avro.io.parsing.Symbol$Sequence.flattenedSize(Symbol.java:324)
{code}
> allow for mutual recursion in type definitions
> ----------------------------------------------
>
> Key: AVRO-530
> URL: https://issues.apache.org/jira/browse/AVRO-530
> Project: Avro
> Issue Type: Improvement
> Components: spec
> Affects Versions: 1.3.2
> Reporter: Jeff Hodges
>
> Suppose you have these two types in your protocol:
> {code}
> {"name": "User", "type": "record", "fields": [{"name": "current_status",
> "type": "Status"}]}
> {"name": "Status", "type": "record", "fields": [{"name": "author", "type":
> "User"}]}
> {code}
> This will raise an error! The current workaround is to define one of them at
> their first usage. Like:
> {code}
> {"name": "User", "type": "record", "fields": [{"name": "current_status",
> "type": {"name": "Status", "type": "record", "fields": [.. lots of fields
> ...]}]}
> {code}
> But this is incredibly unwieldy. It would be really nice for the spec to
> require all the parsers to allow for mutual recursion, instead. It could be
> done by implementing a two-pass parser. One pass to acquire names referenced,
> and a second to fill in those names with their appropriate references.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira