Browse Source

`testThatRemoteErrorsAreWrapped`: use `try` to close query response (#131090)

Explicitly close the ES|QL query response obtained in the test to avoid potential leak.
Pawan Kartik 3 months ago
parent
commit
f536069206

+ 0 - 3
muted-tests.yml

@@ -537,9 +537,6 @@ tests:
 - class: org.elasticsearch.xpack.esql.action.CrossClusterAsyncQueryStopIT
   method: testStopQueryLocal
   issue: https://github.com/elastic/elasticsearch/issues/121672
-- class: org.elasticsearch.xpack.esql.action.EsqlRemoteErrorWrapIT
-  method: testThatRemoteErrorsAreWrapped
-  issue: https://github.com/elastic/elasticsearch/issues/130794
 - class: org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT
   method: test {p0=mtermvectors/10_basic/Tests catching other exceptions per item}
   issue: https://github.com/elastic/elasticsearch/issues/122414

+ 3 - 4
x-pack/plugin/esql/src/internalClusterTest/java/org/elasticsearch/xpack/esql/action/EsqlRemoteErrorWrapIT.java

@@ -34,10 +34,9 @@ public class EsqlRemoteErrorWrapIT extends AbstractCrossClusterTestCase {
             );
         }
 
-        RemoteException wrappedError = expectThrows(
-            RemoteException.class,
-            () -> runQuery("FROM " + REMOTE_CLUSTER_1 + ":*," + REMOTE_CLUSTER_2 + ":* | LIMIT 100", false)
-        );
+        RemoteException wrappedError = expectThrows(RemoteException.class, () -> {
+            try (EsqlQueryResponse ignored = runQuery("FROM " + REMOTE_CLUSTER_1 + ":*," + REMOTE_CLUSTER_2 + ":* | LIMIT 100", false)) {}
+        });
         assertThat(wrappedError.getMessage(), is("Remote [cluster-a] encountered an error"));
     }
 }