Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support enum avro serialization with default value #391

Open
wants to merge 9 commits into
base: 2.18
Choose a base branch
from

Conversation

Sonic-Rage
Copy link

@Sonic-Rage Sonic-Rage commented Sep 8, 2023

Fixes #388.

avro/pom.xml Outdated Show resolved Hide resolved
*
* @since 2.16
*/
private static final JacksonAnnotationIntrospector JACKSON_ANNOTATION_INTROSPECTOR = new JacksonAnnotationIntrospector();
Copy link
Member

@cowtowncoder cowtowncoder Sep 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, AnnotationIntrospector should be passed from outside; it may be reconfigured by caller.
We should not rely on default instance.

This just means some more plumbing of things to get AnnotationIntrospector passed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense. thanks

@cowtowncoder
Copy link
Member

Ok, I realized that the avro core dependency upgrade to 1.9.x would be needed to access "enum default" information (both create and get). But this upgrade is not possible since jackson-dataformat-avro code itself is incompatible with 1.9.x (see #167 f.ex).

So I am not 100% sure this is actually achievable at this point.

I did make couple of changes to PR, but it is unfortunately not in a compilable state.

@cowtowncoder cowtowncoder changed the base branch from 2.16 to 2.18 January 4, 2025 04:57
@cowtowncoder
Copy link
Member

Ok, changed target to 2.18, merged changes and updated call of deprecated method to non-deprecated.

@Sonic-Rage This might be ready for merge, but I think you should have a look.

One thing before merging tho: I think I'd need a CLA (https://github.com/FasterXML/jackson/blob/master/contributor-agreement.pdf) if you didn't send one earlier.
It's usually easiest done by printing the doc, fill & sign, scan/photo, email to cla at fasterxml dot com. Only needs to be done once, before the first contribution merged; one is good for all future contributions.

@@ -169,4 +172,38 @@ public void testSchemaForUntypedMap() throws Exception
verifyException(e, "Maps with non-stringable keys are not supported (yet?)");
}
}

// Issue 388 Default value for enums with class
public void testClassEnumWithDefault() throws Exception
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this test better belongs to EnumTest class.

EnumTest did not exists at the time of this PR yet.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will move.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JsonEnumDefaultValue not supported when using AvroMapper to generate schema from JAVA class
3 participants