Filters seem to not do anything?
See original GitHub issueWhen I run the following snippet…
REFLECTIONS = new Reflections(
new ConfigurationBuilder()
.setUrls(ClasspathHelper.forJavaClassPath())
.setScanners(new SubTypesScanner(true))
.filterInputsBy(
new FilterBuilder()
.excludePackage("java.")
.excludePackage("javax.")
.add((s) -> {return s.contains(".class");}))
);
…I get inter alia the following errors from reflections…
org.reflections.ReflectionsException: could not create class object from file ch/qos/logback/classic/gaffer/ConfigurationDelegate.groovy
at org.reflections.scanners.AbstractScanner.scan(AbstractScanner.java:32)
at org.reflections.Reflections.scan(Reflections.java:253)
at org.reflections.Reflections.scan(Reflections.java:202)
at org.reflections.Reflections.<init>(Reflections.java:123)
...
08:12:57.154 [main] DEBUG org.reflections.Reflections - expanded subtype java.io.OutputStream -> java.io.ByteArrayOutputStream
...
08:12:57.167 [main] WARN org.reflections.Reflections - could not get type for name javax.servlet.ServletContextListener from any class loader
org.reflections.ReflectionsException: could not get type for name javax.servlet.ServletContextListener
at org.reflections.ReflectionUtils.forName(ReflectionUtils.java:390)
at org.reflections.Reflections.expandSuperTypes(Reflections.java:381)
at org.reflections.Reflections.<init>(Reflections.java:126)
…even though I’ve added filters & predicates to remove files that aren’t classe, as well as the java and javax packages!
Is it me misunderstanding/doing something wrong, or is this an actual bug?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5
Top Results From Across the Web
Excel filter not working after certain row - YouTube
But when you run a filter you will see that it does not seem to include what you expected. So below in column...
Read more >How To Deal With A No-Filter Problem | healthsystemcio.com
The term 'without a filter' is a pretty common one used today to describe a person who speaks without tact, seems to blurt...
Read more >Frustrating Design Patterns: Broken Filters
Too often dealing with filters can be frustrating. Let's get them right. That means never freeze the UI on a single input, provide...
Read more >Excel filter not working after a certain row - AuditExcel
Excel filter not working after a certain row. Understanding how this happened, why not to allow Excel to guess, and how to fix...
Read more >How To Deal With The Person Who Has No Filter - LinkedIn
But, lacking a filter is really something different. When someone 'lacks a filter', it means that they don't give consideration to the audience, ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
p.s. Initially I thought the problem was caused by
FilterBuilder
using a somewhat inconsistent combination ofOR
andAND
semantics (sometimes the filter is incremental, sometimes it’s not).A combination of
include + exclude
includes all classes allowed by first predicate and then excludes the remaining ones using the second predicate. AnAND
semantic is implied (the filter is incremental). The class is included only if it passes both filters. Looks ok.A combination of
exclude + exclude
uses theAND
semantic as well (the filter is incremental). A class is included only if it passes both filtersBut a combination of
include + include
is using theOR
semantic - a class is allowed if any of the predicates pass. The filter is not incremental here.Say, I’m using
includePackage("foo")
andinclude(".*BarClass")
.I’d expect only
foo....BarClass
to be included, but it actually includes anything that has the packagefoo
OR has theBarClass
ending.I can create a separate issue 😃.
The behavior in OP is likely caused by
configurationBuilder.setExpandSuperTypes(true)
set by default. The stacktraces containexpandSuperTypes
.Explicitly calling
setExpandSuperTypes(false)
will help.Also, it seems that
expandSuperTypes
is applied AFTER filters.