From 3d2571b4aa4c909f317fa28dd3a245018970258d Mon Sep 17 00:00:00 2001 From: eric-zaharia Date: Thu, 4 Jun 2026 14:35:10 +0300 Subject: [PATCH] fix(java): ensure waitTask exception propagation --- .../src/main/java/com/algolia/search/TaskUtils.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/algoliasearch-core/src/main/java/com/algolia/search/TaskUtils.java b/algoliasearch-core/src/main/java/com/algolia/search/TaskUtils.java index 16f933eca..c3d5196f8 100644 --- a/algoliasearch-core/src/main/java/com/algolia/search/TaskUtils.java +++ b/algoliasearch-core/src/main/java/com/algolia/search/TaskUtils.java @@ -3,6 +3,7 @@ import com.algolia.search.exceptions.AlgoliaApiException; import com.algolia.search.exceptions.AlgoliaRetryException; import com.algolia.search.exceptions.AlgoliaRuntimeException; +import com.algolia.search.exceptions.LaunderThrowable; import com.algolia.search.models.RequestOptions; import com.algolia.search.models.common.TaskStatusResponse; import java.util.Objects; @@ -38,11 +39,13 @@ static void waitTask( try { response = getTaskAsync.apply(taskId, requestOptions).get(); - } catch (InterruptedException | ExecutionException e) { - // If the future was cancelled or the thread was interrupted or future completed - // exceptionally - // We stop - break; + } catch (InterruptedException e) { + // Restore the interrupted status and surface the failure + Thread.currentThread().interrupt(); + throw new AlgoliaRuntimeException(e); + } catch (ExecutionException e) { + // Surface the underlying error + throw LaunderThrowable.launder(e); } if (Objects.equals("published", response.getStatus())) return;