[
https://issues.apache.org/jira/browse/AVRO-171?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12770113#action_12770113
]
Doug Cutting commented on AVRO-171:
-----------------------------------
I take it back, we can represent that, as follows:
{"type": "record", "name": "A", "fields": [
{"name" "b", "type": {"type": "record", "name": "B", "fields": [
{"name" "a", "type": "A"}
]}
]}
However ReflectData doesn't properly generate this. I think Schema#toString()
and Protocol#toString() handle this correctly.
Also, the specific compiler should could generate the protocol's schema as a
constant, so that it doesn't run into problems like this.
> Protocol Introspection can produce invalid forward references
> -------------------------------------------------------------
>
> Key: AVRO-171
> URL: https://issues.apache.org/jira/browse/AVRO-171
> Project: Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.2.0
> Environment: java
> Reporter: Mr Fish
>
> Take a look at this code which is what happens in the SpecificResponder
> handshake.
> // server side
> final Protocol protocol =
> ReflectData.get().getProtocol(MyServiceIface.class);
> final String string = protocol.toString();
> // client side
> Protocol.parse(string);
> If you have a compound object made of
> class A {
> B1 b1;
> B2 b2;
> }
> class B1 {
> X x;
> }
> class B2 {
> X x;
> }
> class X {
> int i;
> }
> Then the types will be built up by RefectData.createSchema()
> A, B1, X, B2
> This is then reversed by RefectData.getProtocol() so B1 has no forward
> reference
> B2, X, B1, A.
> But this breaks B2
> org.apache.avro.SchemaParseException: Undefined name: "X"
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.