Skip to content

Commit

Permalink
Merge pull request #108 from adrienlauer/fix-classnotfound
Browse files Browse the repository at this point in the history
Assume predicates are false when they fail to eval
  • Loading branch information
ejemba authored Aug 4, 2020
2 parents 8d88bd1 + a9cedae commit 176a012
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>io.nuun.kernel</groupId>
<artifactId>kernel</artifactId>
<version>1.0.M10-SNAPSHOT</version>
<version>1.0.M11-SNAPSHOT</version>
</parent>

<artifactId>kernel-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,17 @@
import io.nuun.kernel.core.internal.utils.AssertUtils;
import org.reflections.Reflections;
import org.reflections.Store;
import org.reflections.scanners.ResourcesScanner;
import org.reflections.scanners.Scanner;
import org.reflections.scanners.SubTypesScanner;
import org.reflections.scanners.TypeAnnotationsScanner;
import org.reflections.scanners.TypeElementsScanner;
import org.reflections.scanners.*;
import org.reflections.util.ClasspathHelper;
import org.reflections.util.ConfigurationBuilder;
import org.reflections.util.FilterBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.annotation.Annotation;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.concurrent.Executors;
import java.util.function.Predicate;
import java.util.regex.Pattern;
Expand All @@ -50,6 +43,7 @@

public class ClasspathScannerDisk extends AbstractClasspathScanner
{
private final Logger logger = LoggerFactory.getLogger(ClasspathScannerDisk.class);
private final List<String> packageRoots;
private final ClasspathStrategy classpathStrategy;
private final Set<URL> additionalClasspath;
Expand Down Expand Up @@ -153,7 +147,16 @@ public Collection<Class<?>> scanTypes(final Predicate<Class<?>> predicate)
Collection<Class<?>> filteredTypes = new HashSet<>();
for (Class<?> candidate : forNames(types))
{
if (predicate.test(candidate))
boolean test;
try
{
test = predicate.test(candidate);
} catch(Throwable t)
{
logger.debug("Unable to test predicate {} for candidate {}, ignoring it", predicate, candidate, t);
test = false;
}
if (test)
{
filteredTypes.add(candidate);
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<groupId>io.nuun.kernel</groupId>
<artifactId>kernel</artifactId>
<version>1.0.M10-SNAPSHOT</version>
<version>1.0.M11-SNAPSHOT</version>

<modules>
<module>core</module>
Expand Down
2 changes: 1 addition & 1 deletion specs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<parent>
<groupId>io.nuun.kernel</groupId>
<artifactId>kernel</artifactId>
<version>1.0.M10-SNAPSHOT</version>
<version>1.0.M11-SNAPSHOT</version>
</parent>

<artifactId>kernel-specs</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<parent>
<groupId>io.nuun.kernel</groupId>
<artifactId>kernel</artifactId>
<version>1.0.M10-SNAPSHOT</version>
<version>1.0.M11-SNAPSHOT</version>
</parent>

<artifactId>kernel-tests</artifactId>
Expand Down

0 comments on commit 176a012

Please sign in to comment.