Instead we should use `org.elasticsearch.tasks.CancellableTask#addListener` to add a listener which sets `failure` on cancellation.
x-pack/plugin/snapshot-repo-test-kit/src/main/java/org/elasticsearch/repositories/blobstore/testkit/RepositoryAnalyzeAction.java
return repository.blobStore().blobContainer(repository.basePath().add(blobPath));
        }
        private void runContendedRegisterAnalysis(Releasable ref, ContendedRegisterAnalyzeAction.Request request, DiscoveryNode node) {
            if (isRunning()) {
                transportService.sendChildRequest(
                    node,
                    ContendedRegisterAnalyzeAction.NAME,
                    request,
                    task,
                    TransportRequestOptions.EMPTY,
                    new ActionListenerResponseHandler<>(ActionListener.releaseAfter(new ActionListener<>() {
                        @Override
                        public void onResponse(ActionResponse.Empty response) {
                            expectedRegisterValue.incrementAndGet();
                        }
                        @Override
                        public void onFailure(Exception exp) {
                            logger.debug(() -> "failed [" + request + "] on [" + node + "]", exp);
                            fail(exp);
                        }
                    }, ref), in -> ActionResponse.Empty.INSTANCE, TransportResponseHandler.TRANSPORT_WORKER)
                );
            } else {
                ref.close();
            }
        }
        private Runnable finalRegisterValueVerifier(String registerName, Random random, Releasable ref) {
            return () -> {
                if (isRunning()) {
                    final var expectedFinalRegisterValue = expectedRegisterValue.get();