You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Bartosz Gałek (Jira)" <ji...@apache.org> on 2024/08/22 10:02:00 UTC
[jira] [Created] (AVRO-4040) annotate `getSpecificData` and `getSchema` methods in Avro generated classes
Bartosz Gałek created AVRO-4040:
-----------------------------------
Summary: annotate `getSpecificData` and `getSchema` methods in Avro generated classes
Key: AVRO-4040
URL: https://issues.apache.org/jira/browse/AVRO-4040
Project: Apache Avro
Issue Type: Improvement
Reporter: Bartosz Gałek
While generating a class from my Avro schema, the `getSpecificData` and `getSchema` methods are also added.
https://github.com/apache/avro/blob/main/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm#L180-L183
These methods are not defined in user schemas, which can be confusing.
It's particularly problematic when analyzing such a class (i.e., via reflection or serialization).
Libraries like `Jackson`, `Gson`, or `Springdoc` should ignore these fields. However, each library has its way of ignoring public fields/getters (`@JsonIgnore`, `@Expose`).
The Avro class generator should allow other libraries to handle those "special" methods/fields without introducing additional coupling to those libraries in the Avro project, of course.
I suggest annotating those methods with `@AvroGeneratedMethod` (or existing `@AvroGenerated`) to address this.
Any library that tries to do something with Avro-generated classes can be configured to ignore those Avro-specific methods.
If this plan is ok for maintainers, I could try to make a pull request with my team.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)