This is an automated email from the ASF dual-hosted git repository.
sanjaydutt pushed a commit to branch branch_9x
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/branch_9x by this push:
new 4a562dc9b68 Fix SolrJmxReporterTest#testClosedCore (#2797)
4a562dc9b68 is described below
commit 4a562dc9b68cedd2a84fc3ee778e99cacb3f96e9
Author: Sanjay Dutt <[email protected]>
AuthorDate: Wed Oct 30 21:08:16 2024 +0530
Fix SolrJmxReporterTest#testClosedCore (#2797)
(cherry picked from commit 2d9b47ec96f637886552baa500a5632b952d032e)
---
.../metrics/reporters/SolrJmxReporterTest.java | 35 +++++++++++-----------
1 file changed, 18 insertions(+), 17 deletions(-)
diff --git
a/solr/core/src/test/org/apache/solr/metrics/reporters/SolrJmxReporterTest.java
b/solr/core/src/test/org/apache/solr/metrics/reporters/SolrJmxReporterTest.java
index 4be3a5a583c..3a8f518c53b 100644
---
a/solr/core/src/test/org/apache/solr/metrics/reporters/SolrJmxReporterTest.java
+++
b/solr/core/src/test/org/apache/solr/metrics/reporters/SolrJmxReporterTest.java
@@ -230,28 +230,29 @@ public class SolrJmxReporterTest extends SolrTestCaseJ4 {
assertEquals("Unexpected number of indexDir beans: " + objects.toString(),
1, objects.size());
final ObjectInstance inst = objects.iterator().next();
final AtomicBoolean running = new AtomicBoolean(true);
- try {
- new Thread(
- () -> {
- while (running.get()) {
- try {
- Object value =
TEST_MBEAN_SERVER.getAttribute(inst.getObjectName(), "Value");
- assertNotNull(value);
- } catch (InstanceNotFoundException x) {
- // no longer present
- break;
- } catch (Exception e) {
- fail("Unexpected error retrieving attribute: " + e);
- }
+ Thread testThread =
+ new Thread(
+ () -> {
+ while (running.get()) {
+ try {
+ Object value =
TEST_MBEAN_SERVER.getAttribute(inst.getObjectName(), "Value");
+ assertNotNull(value);
+ } catch (InstanceNotFoundException x) {
+ // no longer present
+ break;
+ } catch (Exception e) {
+ fail("Unexpected error retrieving attribute: " + e);
}
- },
- "TestMBeanThread")
- .start();
-
+ }
+ },
+ "TestMBeanThread");
+ try {
+ testThread.start();
// This should be enough time for the
Thread.sleep(500);
} finally {
running.set(false);
+ testThread.join();
}
h.getCoreContainer().unload(h.getCore().getName());