5050import java .util .Collections ;
5151import java .util .List ;
5252import java .util .concurrent .ConcurrentHashMap ;
53+ import java .util .concurrent .CopyOnWriteArrayList ;
5354import java .util .concurrent .CountDownLatch ;
5455import java .util .concurrent .Semaphore ;
5556import java .util .concurrent .TimeUnit ;
@@ -84,7 +85,6 @@ public class ClusterDisruptionIT extends AbstractDisruptionTestCase {
8485 "org.elasticsearch.discovery:TRACE,org.elasticsearch.action.support.replication:TRACE," +
8586 "org.elasticsearch.cluster.service:TRACE,org.elasticsearch.indices.recovery:TRACE," +
8687 "org.elasticsearch.indices.cluster:TRACE,org.elasticsearch.index.shard:TRACE" )
87- @ AwaitsFix (bugUrl = "https://github.com/elastic/elasticsearch/issues/37810" )
8888 public void testAckedIndexing () throws Exception {
8989
9090 final int seconds = !(TEST_NIGHTLY && rarely ()) ? 1 : 5 ;
@@ -109,7 +109,7 @@ public void testAckedIndexing() throws Exception {
109109 List <Semaphore > semaphores = new ArrayList <>(nodes .size ());
110110 final AtomicInteger idGenerator = new AtomicInteger (0 );
111111 final AtomicReference <CountDownLatch > countDownLatchRef = new AtomicReference <>();
112- final List <Exception > exceptedExceptions = Collections . synchronizedList ( new ArrayList < Exception >() );
112+ final List <Exception > exceptedExceptions = new CopyOnWriteArrayList <>( );
113113
114114 logger .info ("starting indexers" );
115115 try {
@@ -215,19 +215,19 @@ public void testAckedIndexing() throws Exception {
215215 logger .info ("done validating (iteration [{}])" , iter );
216216 }
217217 } finally {
218+ logger .info ("shutting down indexers" );
219+ stop .set (true );
220+ for (Thread indexer : indexers ) {
221+ indexer .interrupt ();
222+ indexer .join (60000 );
223+ }
218224 if (exceptedExceptions .size () > 0 ) {
219225 StringBuilder sb = new StringBuilder ();
220226 for (Exception e : exceptedExceptions ) {
221227 sb .append ("\n " ).append (e .getMessage ());
222228 }
223229 logger .debug ("Indexing exceptions during disruption: {}" , sb );
224230 }
225- logger .info ("shutting down indexers" );
226- stop .set (true );
227- for (Thread indexer : indexers ) {
228- indexer .interrupt ();
229- indexer .join (60000 );
230- }
231231 }
232232 }
233233
0 commit comments