Skip to content

Commit 6f7f156

Browse files
authored
Merge pull request #9568 from oleksabor/clearTempTest
clearing temp directories from CodegenIgnoreProcessorTest
2 parents 5fdfaa4 + d0180a6 commit 6f7f156

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

modules/swagger-codegen/src/test/java/io/swagger/codegen/ignore/CodegenIgnoreProcessorTest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import java.io.IOException;
1313
import java.nio.file.Files;
1414
import java.nio.file.Path;
15+
import java.util.concurrent.ConcurrentLinkedQueue;
1516

1617
public class CodegenIgnoreProcessorTest {
1718

@@ -25,6 +26,7 @@ public class CodegenIgnoreProcessorTest {
2526
private String outputDir;
2627
private File target;
2728
private Path temp;
29+
private static final ConcurrentLinkedQueue<Path> tempQueue = new ConcurrentLinkedQueue<>();
2830

2931
private CodegenIgnoreProcessorTest(String filename, String ignoreDefinition, String description) throws IOException {
3032
this.filename = filename;
@@ -51,6 +53,7 @@ private void prepareTestFiles() throws IOException {
5153
// NOTE: Each test needs its own directory because .swagger-codegen-ignore needs to exist at the root.
5254
temp = Files.createTempDirectory(getClass().getSimpleName());
5355
this.outputDir = temp.toFile().getAbsolutePath();
56+
tempQueue.add(temp);
5457

5558
target = new File(this.outputDir, this.filename);
5659

@@ -73,9 +76,11 @@ private void prepareTestFiles() throws IOException {
7376

7477
@AfterTest
7578
public void afterTest() throws IOException {
76-
if(temp != null && temp.toFile().exists() && temp.toFile().isDirectory()) {
77-
FileUtils.deleteDirectory(temp.toFile());
78-
}
79+
Path t;
80+
while ((t = tempQueue.poll()) != null)
81+
if(t != null && t.toFile().exists() && t.toFile().isDirectory()) {
82+
FileUtils.deleteDirectory(t.toFile());
83+
}
7984
}
8085

8186
@Test

0 commit comments

Comments
 (0)