Apache Solr open-source search software
Fix SolrJmxReporterTest#testClosedCore (#2797)
Sanjay Dutt2d9b47ec96f6
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.javaindex 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 theThread.sleep(500);} finally {running.set(false);+ testThread.join();}h.getCoreContainer().unload(h.getCore().getName());