-
Notifications
You must be signed in to change notification settings - Fork 305
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
FISH-5938 5530 improve cdi scan #5531
Conversation
- removed redundant contains on set - list replaced by set - exclusions extracted because there is no need to discover the same annotation dozentimes and define it as excluded over and over again
- removed redundant contains on set - list replaced by set - exclusions extracted because there is no need to discover the same annotation dozentimes and define it as excluded over and over again
- if the annotation is cdi enabling, then it does not matter whether it is excluded or not
- there we want to list all classes with annotation - if we exclude some custom annotation then only the first class with that annotation was included
} | ||
for (final AnnotationModel am : type.getAnnotations()) { | ||
final AnnotationType at = am.getType(); | ||
if (isCDIEnablingAnnotation(at, exclusions) && type.wasDefinedIn(paths)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this be improved by checking type.wasDefinedIn(paths)
on the outer if/for? Something like !(type instanceof AnnotationType) && type.wasDefinedIn(paths)
. This would avoid annotation analysis for some types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see.
@sgflt Could the prefilled annotation lists be converted to sets? This would speed up contains calls when checking annotation names. |
Sorry for being vague on this and of course it wouldn't be as dramatic an improvement as your changes already are. I'm talking about these:
If those were Sets it would improve on speed a little bit when checking for a class name being contained. And because they are queried at such a high frequency it could make some noticable difference. |
- as they are used for heavy lookups
- this small subset of well known annotations does not solve problem of custom cyclic annotations as they are used in kotlin - f.e. kotlin.Metadata
…otation - pattern is the same as in isCDIEnablingAnnotation
@@ -403,20 +368,29 @@ private static boolean isCDIEnablingAnnotation(AnnotationType annotationType, | |||
public static boolean hasValidAnnotation(Class annotatedClass, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could this method signature be changed to accept validScopes
and excludedScopes
as Set<String>
painlessly? This would make copying the collections obsolete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are placese where constant fields are passed, so we should not modify them. The copy is done on public api level and collections passed as parameter are only local implementation which is safe to verify their modification.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I see.
@@ -95,8 +97,7 @@ public InjectionServicesImpl(InjectionManager injectionMgr, BundleDescriptor con | |||
* @return | |||
*/ | |||
private boolean isInterceptor( Class beanClass ) { | |||
HashSet<String> annos = new HashSet<>(); | |||
annos.add( javax.interceptor.Interceptor.class.getName() ); | |||
final Set<String> annos = Collections.singleton(javax.interceptor.Interceptor.class.getName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This returns an immutable Set. Is this intentional? If you remove the collection copying from the other method modifications of this set will throw an exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I preffer to not modify collections passed as parameter to public API.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Good rule.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, only validScopes are not modified. There it is possible.
- so we can use set directly
@sgflt LGTM. Good job. |
Jenkins test |
1 similar comment
Jenkins test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixes #5530
Testing Performed
Deployment of testcase finished in 5 seconds.