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

InjecteeSkippingAnalyzer not always installed when needed #5745

Closed
arjantijms opened this issue Sep 16, 2024 · 1 comment · Fixed by #5750
Closed

InjecteeSkippingAnalyzer not always installed when needed #5745

arjantijms opened this issue Sep 16, 2024 · 1 comment · Fixed by #5750

Comments

@arjantijms
Copy link
Contributor

org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider.bindHk2ClassAnalyzer() contains code to conditionally install InjecteeSkippingAnalyzer:

int skippedElements = methodsToSkip.size() + fieldsToSkip.size();

ClassAnalyzer customizedClassAnalyzer = skippedElements > 0
            ? new InjecteeSkippingAnalyzer(defaultClassAnalyzer, methodsToSkip, fieldsToSkip, beanManager)
            : defaultClassAnalyzer;

If there are no skipped elements, InjecteeSkippingAnalyzer is not used. This assumes only skippedElements that are detected during startup are being used in this analyzer. This is however not true. Runtime ellements are added as per the following code in org.glassfish.jersey.ext.cdi1x.internal.InjecteeSkippingAnalyzer.addCdiInjectedFieldsToSkip(Set<Field>, Set<Field>):

private void addCdiInjectedFieldsToSkip(Set<Field> skippedFields, Set<Field> originalFields) {
        for (Field field : originalFields) {
            if (field.getAnnotation(Inject.class) != null && !cdiComponentProvider.isHk2ProvidedType(field.getType())) {
                skippedFields.add(field);
            }
        }
    }

Should the optimising check be totally removed and InjecteeSkippingAnalyzer simply always added here?

@jansupol
Copy link
Contributor

jansupol commented Sep 27, 2024

@arjantijms Thanks. We will use the skipping analyzer.
Fixed by #5750.

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

Successfully merging a pull request may close this issue.

2 participants