Skip to content

Commit

Permalink
Make sure InterruptedException isn't thrown in a place it shouldn't be (
Browse files Browse the repository at this point in the history
elastic#94548)

If the mocked handler gets interrupted, just pass it on (like it would
in the non-mocked version)

This fixes elastic#94096
  • Loading branch information
thecoop authored Mar 20, 2023
1 parent 6e21e4a commit b803cf9
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ public void testStopWorksInMiddleOfProcessing() throws Exception {
deadThreadLatch.countDown();
}

@SuppressWarnings("unchecked")
public void testStopWorksIfProcessingDidntReturnYet() throws Exception {
var spiedController = spy(controller);
var service = new FileSettingsService(clusterService, spiedController, env);
Expand All @@ -329,7 +328,12 @@ public void testStopWorksIfProcessingDidntReturnYet() throws Exception {
doAnswer((Answer<ReservedStateChunk>) invocation -> {
// allow the other thread to continue, but hold on a bit to avoid
// completing the task immediately in the main watcher loop
Thread.sleep(1_000);
try {
Thread.sleep(1_000);
} catch (InterruptedException e) {
// pass it on
Thread.currentThread().interrupt();
}
processFileLatch.countDown();
new Thread(() -> {
// Simulate a thread that never allows the completion to complete
Expand Down

0 comments on commit b803cf9

Please sign in to comment.