diff --git a/CHANGELOG b/CHANGELOG
index f3dc6c2..59651d1 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -7,7 +7,7 @@ CHANGELOG
* Bump mockito-core from 2.22.0 to 2.23.0 (#129)
* Bump kemitix-parent from 5.1.1 to 5.2.0 (#130)
* [jenkins] Don't use verify profile with clean phase (#131)
-* Bump classgraph from 4.2.8 to 4.2.9 (#132)
+* Bump classgraph from 4.2.8 to 4.2.12 (#132)(#133)
5.1.0
-----
diff --git a/builder/pom.xml b/builder/pom.xml
index c1cc109..4276b0e 100644
--- a/builder/pom.xml
+++ b/builder/pom.xml
@@ -32,7 +32,7 @@
2.23.0
3.11.1
0.7.0
- 4.2.9
+ 4.2.12
3.0.0
${project.version}
diff --git a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ClassGraphPackageScanner.java b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ClassGraphPackageScanner.java
index e014e85..dd19ef6 100644
--- a/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ClassGraphPackageScanner.java
+++ b/builder/src/main/java/net/kemitix/checkstyle/ruleset/builder/ClassGraphPackageScanner.java
@@ -22,6 +22,7 @@
package net.kemitix.checkstyle.ruleset.builder;
import io.github.classgraph.ClassGraph;
+import io.github.classgraph.ScanResult;
import org.springframework.stereotype.Service;
import java.util.List;
@@ -37,16 +38,25 @@ import java.util.stream.Collectors;
@Service
public class ClassGraphPackageScanner implements PackageScanner {
+ private final ClassGraph classGraph = new ClassGraph();
+
@Override
public final List apply(final RuleSource ruleSource) {
final String basePackage = ruleSource.getBasePackage();
- return new ClassGraph()
- .whitelistPackages(basePackage)
- .scan()
- .getAllStandardClasses()
- .getNames()
- .stream()
- .filter(packageName -> packageName.startsWith(basePackage))
- .collect(Collectors.toList());
+ try (ScanResult scanResult = scanPackage(classGraph, basePackage)) {
+ return scanResult
+ .getAllStandardClasses()
+ .getNames()
+ .stream()
+ .filter(packageName -> packageName.startsWith(basePackage))
+ .collect(Collectors.toList());
+ }
}
+
+ private static ScanResult scanPackage(final ClassGraph classGraph, final String basePackage) {
+ return classGraph
+ .whitelistPackages(basePackage)
+ .scan();
+ }
+
}