[
https://issues.apache.org/jira/browse/AVRO-4332?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18108683#comment-18108683
]
ASF subversion and git services commented on AVRO-4332:
-------------------------------------------------------
Commit cff8d11d0de6b3cfe8941775abcf151a801de1e2 in avro's branch
refs/heads/dependabot/npm_and_yarn/lang/js/mocha-11.8.0 from prygunovx
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=cff8d11d0d ]
AVRO-4332: [java] Add support for enum default values in IDL serialization
IdlUtils.writeSchema did not emit the enum default when serializing a
schema to IDL, even though IdlReader parses it. As a result, an enum
default was silently dropped when round-tripping a schema through IDL.
Append "= <default>;" after the enum body when the schema has a default,
matching the IDL grammar (RBrace defaultSymbol=enumDefault?), and add
tests covering the with-default, without-default and write-then-parse
round-trip cases.
> IDL writer does not serialize enum default values
> -------------------------------------------------
>
> Key: AVRO-4332
> URL: https://issues.apache.org/jira/browse/AVRO-4332
> Project: Apache Avro
> Issue Type: Bug
> Components: java
> Affects Versions: 1.12.1, 1.13.0, 1.12.2
> Reporter: Maxim Prygunov
> Assignee: Maxim Prygunov
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.13.0
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> When an Avro Schema of type ENUM has a default value set (via
> Schema.createEnum(name, doc, namespace, symbols, enumDefault)), the IDL
> writer in IdlUtils.writeSchema() does not serialize the default value into
> the IDL output.
> For example, given an enum schema with "default": "ACTIVE":
> 1 Schema enumWithDefault = Schema.createEnum("Status", null, "naming",
> 2 Arrays.asList("ACTIVE", "INACTIVE"), "ACTIVE");
> Calling IdlUtils.writeIdlProtocol(writer, enumWithDefault) produces:
> 1 enum Status \{ ACTIVE, INACTIVE }
> But the correct IDL representation should be:
> 1 enum Status \{ ACTIVE, INACTIVE } = ACTIVE;
> This means round-tripping (IDL → Schema → IDL) loses the default value
> information for enums, which can cause downstream issues in code generators
> and schema validation.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)