1212import java .io .IOException ;
1313import java .nio .file .Files ;
1414import java .nio .file .Path ;
15+ import java .util .concurrent .ConcurrentLinkedQueue ;
1516
1617public 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