From 5f871b1dc64e151d7cc5dd0464913fedf021f74e Mon Sep 17 00:00:00 2001 From: Arun Sharma Date: Fri, 16 Oct 2026 13:30:19 -0700 Subject: [PATCH] fix(build): retry Maven Central downloads CI hit a transient Maven Central failure configuring the Java API: Failed to download Maven artifact org.apache.arrow:arrow-c-data:18.2.0 ... "HTTP response code said error" Retry the download up to 5 times with a 10s backoff (removing any partial file between attempts) before failing the configure step. --- CMakeLists.txt | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 14b770c..288f98a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,17 +46,35 @@ function(lbug_download_maven_jar out_var group_id artifact_id version) if(NOT EXISTS "${local_path}") message(STATUS "Downloading ${group_id}:${artifact_id}:${version}") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/maven_cache") - file(DOWNLOAD "${url}" "${local_path}" - STATUS download_status - LOG download_log - TLS_VERIFY ON) - list(GET download_status 0 status_code) - list(GET download_status 1 error_msg) - if(NOT status_code EQUAL 0) - message(FATAL_ERROR - "Failed to download Maven artifact ${group_id}:${artifact_id}:${version} " - "from ${url}: ${error_msg}") - endif() + # Maven Central occasionally flakes (HTTP errors / rate limits), as seen + # in CI with arrow-c-data. Retry a few times before failing the build. + set(_lbug_dl_attempt 0) + set(_lbug_dl_max_attempts 5) + while(_lbug_dl_attempt LESS _lbug_dl_max_attempts) + math(EXPR _lbug_dl_attempt "${_lbug_dl_attempt} + 1") + file(DOWNLOAD "${url}" "${local_path}" + STATUS download_status + LOG download_log + TLS_VERIFY ON + TIMEOUT 120) + list(GET download_status 0 status_code) + list(GET download_status 1 error_msg) + if(status_code EQUAL 0) + break() + endif() + # Remove any partial file so the next attempt starts clean. + file(REMOVE "${local_path}") + if(_lbug_dl_attempt LESS _lbug_dl_max_attempts) + message(STATUS "Download attempt ${_lbug_dl_attempt}/${_lbug_dl_max_attempts} " + "for ${group_id}:${artifact_id}:${version} failed (${error_msg}); " + "retrying in 10s...") + execute_process(COMMAND ${CMAKE_COMMAND} -E sleep 10) + else() + message(FATAL_ERROR + "Failed to download Maven artifact ${group_id}:${artifact_id}:${version} " + "from ${url} after ${_lbug_dl_max_attempts} attempts: ${error_msg}") + endif() + endwhile() endif() set(${out_var} "${local_path}" PARENT_SCOPE) endfunction()