You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Elliot West (JIRA)" <ji...@apache.org> on 2017/03/20 11:40:41 UTC
[jira] [Updated] (AVRO-1963) SchemaBuilder: Redefined records
should fail fast
[ https://issues.apache.org/jira/browse/AVRO-1963?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Elliot West updated AVRO-1963:
------------------------------
Labels: schemabuilder (was: )
> 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
> Priority: Minor
> Labels: schemabuilder
>
> 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.15#6346)