Skip to content

Commit f5c0fa8

Browse files
committed
fix: add the try-with-resource when use URLClassLoader
1 parent 3e45a6f commit f5c0fa8

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

src/main/java/org/fugerit/java/junit5/tag/check/ExecutedTestTagReporterMojo.java

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,29 @@ public void execute() throws MojoExecutionException {
6161

6262
try {
6363
// Build classpath for test classes
64-
URLClassLoader classLoader = createTestClassLoader();
64+
try (URLClassLoader classLoader = createTestClassLoader()) {
6565

66-
// Parse Surefire reports to find executed tests
67-
List<ExecutedTest> executedTests = TagSurefireFacade.parseSurefireReports( this.surefireReportsDirectory, this.includeSkipped );
66+
// Parse Surefire reports to find executed tests
67+
List<ExecutedTest> executedTests = TagSurefireFacade.parseSurefireReports( this.surefireReportsDirectory, this.includeSkipped );
6868

69-
getLog().info("Found " + executedTests.size() + " executed tests");
69+
getLog().info("Found " + executedTests.size() + " executed tests");
7070

71-
// Extract tags from executed tests
72-
Map<ExecutedTest, Set<String>> testTagMap =
73-
TagScanFacade.extractTagsFromExecutedTests(executedTests, classLoader);
71+
// Extract tags from executed tests
72+
Map<ExecutedTest, Set<String>> testTagMap =
73+
TagScanFacade.extractTagsFromExecutedTests(executedTests, classLoader);
7474

75-
// Generate report
76-
TagReportFacade.generateReport( this.format, this.includeSkipped, this.outputFile, testTagMap);
75+
// Generate report
76+
TagReportFacade.generateReport( this.format, this.includeSkipped, this.outputFile, testTagMap);
7777

78-
// Check for required tags
79-
if (requiredTags != null && !requiredTags.isEmpty()) {
80-
TagCheckFacade.checkRequiredTags( this.requiredTags, this.failOnMissingTag, testTagMap);
81-
}
78+
// Check for required tags
79+
if (requiredTags != null && !requiredTags.isEmpty()) {
80+
TagCheckFacade.checkRequiredTags( this.requiredTags, this.failOnMissingTag, testTagMap);
81+
}
82+
83+
getLog().info("Executed Test Tag Report generated: " +
84+
outputFile.getAbsolutePath());
8285

83-
getLog().info("Executed Test Tag Report generated: " +
84-
outputFile.getAbsolutePath());
86+
}
8587

8688
} catch (Exception e) {
8789
throw new MojoExecutionException("Error generating executed test tag report", e);

0 commit comments

Comments
 (0)