From e22bef6c4a05f00ec21456fa1847e76ab8e3bb34 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Thu, 12 Sep 2024 16:12:43 +1000 Subject: [PATCH] Do not throw in task enqueued by CancellableRunner (#112780) CancellableThreads#excute can throw runtime exception including cancellation. This does not work with AbstractThrottledTaskRunner which expects enqueued task to _not_ throw. This PR catches any runtime exception from CancellableThreads and hand it back to the original runnable. Resolves: #112779 --- muted-tests.yml | 3 --- .../testkit/integrity/RepositoryIntegrityVerifier.java | 6 +++++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/muted-tests.yml b/muted-tests.yml index 7d170a5e8db2d..f7ac0ad55e2e7 100644 --- a/muted-tests.yml +++ b/muted-tests.yml @@ -211,9 +211,6 @@ tests: - class: org.elasticsearch.repositories.blobstore.testkit.integrity.RepositoryVerifyIntegrityIT method: testCorruption issue: https://github.com/elastic/elasticsearch/issues/112769 -- class: org.elasticsearch.repositories.blobstore.testkit.integrity.RepositoryVerifyIntegrityIT - method: testTransportException - issue: https://github.com/elastic/elasticsearch/issues/112779 - class: org.elasticsearch.script.StatsSummaryTests method: testEqualsAndHashCode issue: https://github.com/elastic/elasticsearch/issues/112439 diff --git a/x-pack/plugin/snapshot-repo-test-kit/src/main/java/org/elasticsearch/repositories/blobstore/testkit/integrity/RepositoryIntegrityVerifier.java b/x-pack/plugin/snapshot-repo-test-kit/src/main/java/org/elasticsearch/repositories/blobstore/testkit/integrity/RepositoryIntegrityVerifier.java index a5c81d18071fc..e10fe2b756f78 100644 --- a/x-pack/plugin/snapshot-repo-test-kit/src/main/java/org/elasticsearch/repositories/blobstore/testkit/integrity/RepositoryIntegrityVerifier.java +++ b/x-pack/plugin/snapshot-repo-test-kit/src/main/java/org/elasticsearch/repositories/blobstore/testkit/integrity/RepositoryIntegrityVerifier.java @@ -934,7 +934,11 @@ public void onResponse(Releasable releasable) { if (cancellableThreads.isCancelled()) { runnable.onFailure(new TaskCancelledException("task cancelled")); } else { - cancellableThreads.execute(runnable::run); + try { + cancellableThreads.execute(runnable::run); + } catch (RuntimeException e) { + runnable.onFailure(e); + } } } }