Skip to content

Commit 22fa580

Browse files
committed
ESIntegTestCase always cleans up static fields
ESIntegTestCase has logic to clean up static fields in a method annotated with `@AfterClass` so that these fields do not trigger the StaticFieldsInvariantRule. However, during the exceptional close of the test cluster, this cleanup can be missed. The StaticFieldsInvariantRule always runs and will attempt to inspect the size of the static fields that were not cleaned up. If the `currentCluster` field of ESIntegTestCase references an InternalTestCluster, this could hold a reference to an implementation of a `Path` that comes from the `sun.nio.fs` package, which the security manager will deny access to. This casues additional noise to be generated since the AccessControlException will cause the StaticFieldsInvariantRule to fail and also be reported along with the actual exception that occurred. This change clears the static fields of ESIntegTestCase in a finally block inside the `@AfterClass` method to prevent this unneessary noise. Closes elastic#41526
1 parent e0df257 commit 22fa580

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

test/framework/src/main/java/org/elasticsearch/test/ESIntegTestCase.java

+8-8
Original file line numberDiff line numberDiff line change
@@ -1947,19 +1947,19 @@ public final void cleanUpCluster() throws Exception {
19471947

19481948
@AfterClass
19491949
public static void afterClass() throws Exception {
1950-
if (!runTestScopeLifecycle()) {
1951-
try {
1950+
try {
1951+
if (runTestScopeLifecycle()) {
1952+
clearClusters();
1953+
} else {
19521954
INSTANCE.printTestMessage("cleaning up after");
19531955
INSTANCE.afterInternal(true);
19541956
checkStaticState(true);
1955-
} finally {
1956-
INSTANCE = null;
19571957
}
1958-
} else {
1959-
clearClusters();
1958+
} finally {
1959+
SUITE_SEED = null;
1960+
currentCluster = null;
1961+
INSTANCE = null;
19601962
}
1961-
SUITE_SEED = null;
1962-
currentCluster = null;
19631963
}
19641964

19651965
private static void initializeSuiteScope() throws Exception {

0 commit comments

Comments
 (0)