Skip to content

Commit b6ec066

Browse files
authored
ESIntegTestCase always cleans up static fields (#49105) (#49108)
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 unnecessary noise. Closes #41526
1 parent eca93fc commit b6ec066

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
@@ -2114,19 +2114,19 @@ public final void cleanUpCluster() throws Exception {
21142114

21152115
@AfterClass
21162116
public static void afterClass() throws Exception {
2117-
if (!runTestScopeLifecycle()) {
2118-
try {
2117+
try {
2118+
if (runTestScopeLifecycle()) {
2119+
clearClusters();
2120+
} else {
21192121
INSTANCE.printTestMessage("cleaning up after");
21202122
INSTANCE.afterInternal(true);
21212123
checkStaticState(true);
2122-
} finally {
2123-
INSTANCE = null;
21242124
}
2125-
} else {
2126-
clearClusters();
2125+
} finally {
2126+
SUITE_SEED = null;
2127+
currentCluster = null;
2128+
INSTANCE = null;
21272129
}
2128-
SUITE_SEED = null;
2129-
currentCluster = null;
21302130
}
21312131

21322132
private static void initializeSuiteScope() throws Exception {

0 commit comments

Comments
 (0)