@@ -150,7 +150,7 @@ public void testAddedListenersReleasedOnCompletion() {
150150 reachabilityChecker .ensureUnreachable ();
151151 }
152152
153- public void testRejection () throws Exception {
153+ public void testRejection () {
154154 final CyclicBarrier barrier = new CyclicBarrier (2 );
155155 final EsThreadPoolExecutor executorService = EsExecutors .newFixed (
156156 "testRejection" ,
@@ -163,15 +163,11 @@ public void testRejection() throws Exception {
163163
164164 try {
165165 executorService .execute (() -> {
166- try {
167- barrier .await (10 , TimeUnit .SECONDS ); // notify main thread that the executor is blocked
168- barrier .await (10 , TimeUnit .SECONDS ); // wait for main thread to release us
169- } catch (Exception e ) {
170- throw new AssertionError ("unexpected" , e );
171- }
166+ safeAwait (barrier ); // notify main thread that the executor is blocked
167+ safeAwait (barrier ); // wait for main thread to release us
172168 });
173169
174- barrier . await ( 10 , TimeUnit . SECONDS ); // wait for executor to be blocked
170+ safeAwait ( barrier ); // wait for executor to be blocked
175171
176172 final var listenableFuture = new ListenableFuture <Void >();
177173 final var future1 = new PlainActionFuture <Void >();
@@ -190,7 +186,7 @@ public void testRejection() throws Exception {
190186 assertFalse (future1 .isDone ()); // still waiting in the executor queue
191187 assertTrue (future2 .isDone ()); // rejected from the executor on this thread
192188
193- barrier . await ( 10 , TimeUnit . SECONDS ); // release blocked executor
189+ safeAwait ( barrier ); // release blocked executor
194190
195191 if (success ) {
196192 expectThrows (EsRejectedExecutionException .class , future2 ::result );
0 commit comments