elastic/elasticsearch · error · IOException
Interrupted while retrying download from: {}
Error message
Interrupted while retrying download from: {} What it means
Raised by readHttpBytesWithRetry when the thread is interrupted during the inter-attempt backoff sleep. The method re-asserts the interrupt status (Thread.currentThread().interrupt()) and wraps the InterruptedException in an IOException so the checked-interrupt contract is preserved while still failing the download. The offending URL is included.
Source
Thrown at build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/util/HttpUtils.java:47
}
public static byte[] readHttpBytesWithRetry(String url, int maxAttempts, long baseBackoffMillis, Sleeper sleeper) throws IOException {
if (maxAttempts <= 0) {
throw new IllegalArgumentException("maxAttempts must be >= 1 but was [" + maxAttempts + "]");
}
if (baseBackoffMillis < 0) {
throw new IllegalArgumentException("baseBackoffMillis must be >= 0 but was [" + baseBackoffMillis + "]");
}
IOException lastException = null;
for (int attempt = 1; attempt <= maxAttempts; attempt++) {
if (attempt > 1 && baseBackoffMillis > 0) {
long backoff = baseBackoffMillis * (attempt - 1);
try {
sleeper.sleep(backoff);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IOException("Interrupted while retrying download from: " + url, e);
}
}
try (InputStream in = URI.create(url).toURL().openStream()) {
return in.readAllBytes();
} catch (IOException e) {
lastException = e;
}
}
assert lastException != null;
throw lastException;
}
}
View on GitHub (pinned to db6a809a66)
Solutions
- If the interrupt was unintentional, find the source of Thread.interrupt() / executor shutdown and avoid cancelling the download prematurely.
- Treat this as a normal abort: let the IOException propagate and ensure callers release partial resources.
- If downloads must be cancellable, design an explicit cancellation flag instead of relying on thread interruption.
Defensive patterns
Strategy: try-catch
Try / catch
try {
bytes = HttpUtils.readHttpBytesWithRetry(url);
} catch (IOException e) {
if (Thread.currentThread().isInterrupted()) {
// download aborted via interrupt; release partial resources, re-flag interrupt
Thread.currentThread().interrupt();
throw e;
}
// genuine network failure - retry/fallback as needed
} Prevention
- Don't interrupt worker threads that are mid-download unless you intend to abort.
- Use a cooperative cancellation flag instead of Thread.interrupt() for cancellable downloads.
- Always restore the interrupt flag in catch blocks that handle InterruptedException/IOException-from-interrupt.
When it happens
Trigger: A Gradle build task or worker thread calling readHttpBytesWithRetry is cancelled (e.g. build aborted, executor shutdown) mid-backoff between HTTP attempts; a test injects an interrupt to abort a hanging download.
Common situations: User cancels a long-running Gradle download task; a worker thread pool is shut down during resource fetching; CI timeout interrupts the build while it retries a flaky URL.
Related errors
- Failed to pull Docker base image [{baseImage}], all attempts
- Failed to download branches.json from: {}
- Failed to fetch branch {normalizedBranch} from {sourceRepo}
- Uploading Snyk Graph failed with http code {}: {}
- Failed to call API endpoint to submit updated dependency gra
AI-assisted analysis of elastic/elasticsearch@db6a809a66 (2026-08-12).
Data as JSON: /api/errors/58de5b27004336e8.
Report an issue: GitHub.