Skip to content
Permalink
Browse files

excluding proxy classes from search

  • Loading branch information...
arcuri82 committed Sep 29, 2019
1 parent 11cef0f commit 22dc92d81b65419d8b5e5ac1b1f17eddce2afb42
@@ -90,7 +90,18 @@ public Instrumentator(String packagePrefixesToCover) {

private boolean canInstrumentForCoverage(ClassName className){

return prefixes.stream()
.anyMatch(s -> className.getFullNameWithDots().startsWith(s));
String name = className.getFullNameWithDots();

/*
we need to exclude classes that are automatically generated at runtime, eg like
proxies in Spring.
TODO is there an easy way to detect it besides checking for pattern names common in
existing libraries? Doesn't look like...
https://stackoverflow.com/questions/7504509/java-detect-if-class-is-a-proxy
*/
List<String> exclusions = Arrays.asList("BySpringCGLIB");

return prefixes.stream().anyMatch(s -> name.startsWith(s))
&& exclusions.stream().noneMatch(s -> name.contains(s));
}
}

0 comments on commit 22dc92d

Please sign in to comment.
You can’t perform that action at this time.