Copilot commented on code in PR #13427:
URL: https://github.com/apache/cloudstack/pull/13427#discussion_r3624958874
##########
utils/src/main/java/com/cloud/utils/ReflectUtil.java:
##########
@@ -70,9 +71,12 @@ public static Set<Class<?>> getClassesWithAnnotation(Class<?
extends Annotation>
Reflections reflections;
Set<Class<?>> classes = new HashSet<Class<?>>();
ConfigurationBuilder builder=new ConfigurationBuilder();
+ FilterBuilder filterBuilder = new FilterBuilder();
for (String packageName : packageNames) {
builder.addUrls(ClasspathHelper.forPackage(packageName));
+ filterBuilder.includePackage(packageName);
}
+ builder.filterInputsBy(filterBuilder);
builder.setScanners(new SubTypesScanner(),new
TypeAnnotationsScanner());
Review Comment:
`getClassesWithAnnotation` now filters inputs via
`FilterBuilder.includePackage(...)`, which changes discovery behavior (it can
now exclude classes that were previously returned if the include patterns don’t
match as expected). There are existing unit tests for `ReflectUtil`, but none
cover `getClassesWithAnnotation`; adding a targeted test would help prevent
regressions (e.g., define a test-only annotation + annotated class in the test
classpath and assert it’s discovered when scanning the test package, and that
unrelated packages are not scanned/returned).
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]