Skip to content

Commit 7520025

Browse files
committed
[TEST] Fix RemoteClusterConnectionTests
With PR #31574 we now ensure that connections are established under the proper thread context. There is a test in RemoteClusterConnectionTests, however, that shuts down the service while connecting. With the above change, a new kind of exception can occur that the test is unaware of.
1 parent 61eefc8 commit 7520025

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

server/src/test/java/org/elasticsearch/transport/RemoteClusterConnectionTests.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777

7878
import static java.util.Collections.emptyMap;
7979
import static java.util.Collections.emptySet;
80+
import static org.hamcrest.Matchers.containsString;
8081
import static org.hamcrest.Matchers.equalTo;
8182
import static org.hamcrest.Matchers.instanceOf;
8283
import static org.hamcrest.Matchers.iterableWithSize;
@@ -854,7 +855,13 @@ public void run() {
854855
throw new AssertionError(x);
855856
}
856857
});
857-
connection.updateSeedNodes(seedNodes, listener);
858+
try {
859+
connection.updateSeedNodes(seedNodes, listener);
860+
} catch (Exception e) {
861+
// it's ok if we're shutting down
862+
assertThat(e.getMessage(), containsString("threadcontext is already closed"));
863+
latch.countDown();
864+
}
858865
}
859866
latch.await();
860867
} catch (Exception ex) {

0 commit comments

Comments
 (0)