[
https://issues.apache.org/jira/browse/AVRO-1963?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Elliot West updated AVRO-1963:
------------------------------
Summary: SchemaBuilder: Redefined records should fail fast (was: Redefined
records should fail fast)
> SchemaBuilder: Redefined records should fail fast
> -------------------------------------------------
>
> Key: AVRO-1963
> URL: https://issues.apache.org/jira/browse/AVRO-1963
> Project: Avro
> Issue Type: Bug
> Affects Versions: 1.7.7, 1.8.1
> Reporter: Elliot West
>
> h2. Overview
> It is currently possible to build an invalid {{Schema}} instance using the
> {{SchemaBuilder}}, without any error being thrown. The schema in question is
> invalid because of redefined record types. These are not picked up by the
> {{SchemaBuilder}}. Failure eventually occurs when calling the
> {{Schema.toString()}} method.
> I suggest that failure should occur much earlier such as at the point of
> introduction of the redeclared record name in the case of {{SchemaBuilder}}.
> This would make it easier for users to better determine the point of origin
> of their schema issues.
> Note that there does not appear to be a similar issue with the
> {{Schema.parse(String)}} method which fails fast as expected.
> h2. Test case
> {code:title=Test case}
> Schema a =
> SchemaBuilder.record("A").fields().optionalInt("y").endRecord();
> Schema b =
> SchemaBuilder.record("A").fields().optionalString("x").endRecord();
> Schema s = SchemaBuilder
> .record("S")
> .fields()
> .name("a")
> .type(a)
> .noDefault()
> .name("b")
> .type(b)
> .noDefault()
> .endRecord();
> // Does not fail
>
> s.toString();
> // Fails with org.apache.avro.SchemaParseException: Can't redefine: A
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)