[
https://issues.apache.org/jira/browse/AVRO-4332?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18105491#comment-18105491
]
ASF subversion and git services commented on AVRO-4332:
-------------------------------------------------------
Commit 326950f40c1172f7564c757b0e51c39883721083 in avro's branch
refs/heads/main from Ismaël Mejía
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=326950f40c ]
AVRO-4332: [java] Enable and fix the dormant IdlUtils tests
The IdlUtils test class was never executed: Surefire only includes
classes matching **/Test** (name starting with "Test"), but the class
was named IdlUtilsTest, so its tests silently rotted since AVRO-3677.
Rename IdlUtilsTest to TestIdlUtils so the suite runs, and fix the
problems this uncovers:
- byte[] values serialized to an empty string because the byte[]
serializer discarded MAPPER.writeValueAsString(...) instead of
writing to the generator; write the value to the generator.
- The callToJson test helper had the same discard bug, so every
*ToJson assertion previously compared against an empty string.
- The happy-flow fixtures lived under org/apache/avro/util and were
unreachable from the org.apache.avro.idl package; move them beside
the test and regenerate them from the current writer output.
- getMainSchema() now returns the record directly, so drop the
obsolete union unwrapping in validateHappyFlowForSingleSchema.
- Map/collection JSON expectations now include the ", " separator the
MAPPER emits.
> 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
> 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)