You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by "ashley-taylor (via GitHub)" <gi...@apache.org> on 2025/11/10 03:10:52 UTC
Re: [PR] AVRO-1759: [java] Automatic union types for sealed classes [avro]
ashley-taylor commented on code in PR #3436:
URL: https://github.com/apache/avro/pull/3436#discussion_r2508588939
##########
lang/java/avro/src/main/java/org/apache/avro/reflect/ReflectData.java:
##########
@@ -811,10 +830,29 @@ private void setElement(Schema schema, Type element) {
schema.addProp(ELEMENT_PROP, c.getName());
}
+ private Class[] getUnion(AnnotatedElement element) {
+ Union union = element.getAnnotation(Union.class);
+ if (union != null) {
+ return union.value();
+ }
+
+ if (element instanceof Class) {
+ // automatic sealed class polymorphic
+ try {
+ if (IS_SEALED_METHOD != null && Boolean.TRUE.equals(IS_SEALED_METHOD.invoke(element))) {
+ return (Class<?>[]) GET_PERMITTED_SUBCLASSES_METHOD.invoke(element);
Review Comment:
@martin-g thanks for the review. Have made it skip the abstract and recursive.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org