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

References to enums in annotations missing from classpath break introspections #6772

Open
yawkat opened this issue Jan 18, 2022 · 0 comments
Labels
type: improvement A minor improvement to an existing feature

Comments

@yawkat
Copy link
Member

yawkat commented Jan 18, 2022

Issue description

Annotations that are generated by annotation transformers, that reference enum values, break the introspection they're on when that enum isn't present on the classpath.

This was a problem in the micronaut-security changes for micronaut-serialization. The micronaut-serialization annotation processor transforms jackson annotations to its own internal annotation model. The internal annotations may not be present on the classpath if jackson is used for serialization.

This would lead to the following error: https://ge.micronaut.io/s/5gde4hmsyj374/failure?expanded-stacktrace=WyIwLTgtMTEtMTQtMTctMjAiLCI3LTEwLTEzLTE2LTE5LTIyIl0#1 (can't see how to copy the stack trace and I don't have it around locally anymore)

This error happens because the generated introspection class tries to access the missing enum constant.

For "normal" annotations, where no transformer is in play, this isn't an issue, because the enum values are written as strings and resolved lazily on request. This is also the approach I've used to fix this issue in micronaut-serialization: micronaut-projects/micronaut-serialization#115

We should consider doing this for all annotation enum values, e.g. by changing AnnotationValueBuilder to transform all enum values to strings. This will not have a negative correctness impact, since strings can always be lazily converted back, but it may have a negative impact on performance (constant load is faster than the valueOf call).

@yawkat yawkat added the type: improvement A minor improvement to an existing feature label Jan 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: improvement A minor improvement to an existing feature
Projects
None yet
Development

No branches or pull requests

1 participant