Skip to content

Commit 90f49de

Browse files
authored
Delete temp jars in classfile tests sooner (elastic#93019)
This commit more aggressively deletes the temporary jar files produced to test jar scanning for plugins. By deleting right after use, any leaked file handles should cause the tests to fail on windows. relates elastic#93005
1 parent 808ce72 commit 90f49de

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

libs/plugin-scanner/src/test/java/org/elasticsearch/plugin/scanner/ClassReadersTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
package org.elasticsearch.plugin.scanner;
1010

11+
import org.elasticsearch.core.IOUtils;
1112
import org.elasticsearch.test.ESTestCase;
1213
import org.elasticsearch.test.compiler.InMemoryJavaCompiler;
1314
import org.elasticsearch.test.jar.JarUtils;
@@ -39,6 +40,9 @@ public void testModuleInfoIsNotReturnedAsAClassFromJar() throws IOException {
3940

4041
List<ClassReader> classReaders = ClassReaders.ofPaths(Stream.of(jar));
4142
org.hamcrest.MatcherAssert.assertThat(classReaders, Matchers.empty());
43+
44+
// aggressively delete the jar dir, so that any leaked filed handles fail this specific test on windows
45+
IOUtils.rm(tmp);
4246
}
4347

4448
public void testTwoClassesInAStreamFromJar() throws IOException {
@@ -57,6 +61,9 @@ public class B {}
5761
List<ClassReader> classReaders = ClassReaders.ofPaths(Stream.of(jar));
5862
List<String> collect = classReaders.stream().map(cr -> cr.getClassName()).collect(Collectors.toList());
5963
org.hamcrest.MatcherAssert.assertThat(collect, Matchers.containsInAnyOrder("p/A", "p/B"));
64+
65+
// aggressively delete the jar dir, so that any leaked filed handles fail this specific test on windows
66+
IOUtils.rm(tmp);
6067
}
6168

6269
public void testStreamOfJarsAndIndividualClasses() throws IOException {

libs/plugin-scanner/src/test/java/org/elasticsearch/plugin/scanner/NamedComponentScannerTests.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
package org.elasticsearch.plugin.scanner;
1010

11+
import org.elasticsearch.core.IOUtils;
1112
import org.elasticsearch.plugin.scanner.test_model.ExtensibleClass;
1213
import org.elasticsearch.plugin.scanner.test_model.ExtensibleInterface;
1314
import org.elasticsearch.plugin.scanner.test_model.TestNamedComponent;
@@ -100,6 +101,9 @@ public class B implements ExtensibleInterface{}
100101
)
101102
)
102103
);
104+
105+
// aggressively delete the jar dir, so that any leaked filed handles fail this specific test on windows
106+
IOUtils.rm(tmp);
103107
}
104108

105109
public void testNamedComponentsCanExtednCommonSuperClass() throws IOException {
@@ -174,6 +178,9 @@ public class B implements CustomExtensibleInterface{}
174178
)
175179
)
176180
);
181+
182+
// aggressively delete the jar dir, so that any leaked filed handles fail this specific test on windows
183+
IOUtils.rm(tmp);
177184
}
178185

179186
public void testWriteToFile() throws IOException {

0 commit comments

Comments
 (0)