|
49 | 49 |
|
50 | 50 | import static org.elasticsearch.index.seqno.SequenceNumbers.NO_OPS_PERFORMED; |
51 | 51 | import static org.elasticsearch.index.seqno.SequenceNumbers.UNASSIGNED_SEQ_NO; |
| 52 | +import static org.hamcrest.Matchers.any; |
52 | 53 | import static org.hamcrest.Matchers.containsString; |
53 | 54 | import static org.hamcrest.Matchers.equalTo; |
54 | 55 | import static org.hamcrest.Matchers.hasToString; |
55 | 56 | import static org.hamcrest.Matchers.instanceOf; |
| 57 | +import static org.mockito.Matchers.argThat; |
| 58 | +import static org.mockito.Mockito.doAnswer; |
56 | 59 | import static org.mockito.Mockito.mock; |
57 | 60 | import static org.mockito.Mockito.reset; |
58 | 61 | import static org.mockito.Mockito.times; |
@@ -561,19 +564,19 @@ public void testTimeoutNotificationUsesExecutor() throws InterruptedException { |
561 | 564 | } |
562 | 565 |
|
563 | 566 | public void testFailingListenerAfterTimeout() throws InterruptedException { |
| 567 | + final CountDownLatch latch = new CountDownLatch(1); |
564 | 568 | final Logger mockLogger = mock(Logger.class); |
| 569 | + doAnswer(invocationOnMock -> { |
| 570 | + latch.countDown(); |
| 571 | + return null; |
| 572 | + }).when(mockLogger).warn(argThat(any(String.class)), argThat(any(RuntimeException.class))); |
565 | 573 | final GlobalCheckpointListeners globalCheckpointListeners = |
566 | 574 | new GlobalCheckpointListeners(shardId, Runnable::run, scheduler, mockLogger); |
567 | | - final CountDownLatch latch = new CountDownLatch(1); |
568 | 575 | final TimeValue timeout = TimeValue.timeValueMillis(randomIntBetween(1, 50)); |
569 | 576 | globalCheckpointListeners.add( |
570 | 577 | NO_OPS_PERFORMED, |
571 | 578 | (g, e) -> { |
572 | | - try { |
573 | | - throw new RuntimeException("failure"); |
574 | | - } finally { |
575 | | - latch.countDown(); |
576 | | - } |
| 579 | + throw new RuntimeException("failure"); |
577 | 580 | }, |
578 | 581 | timeout); |
579 | 582 | latch.await(); |
|
0 commit comments