This is an automated email from the ASF dual-hosted git repository.

HyukjinKwon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new 421067d264f3 [SPARK-58025][INFRA] Redirect build/mvn fallback message 
to stderr to avoid corrupting version captures
421067d264f3 is described below

commit 421067d264f39159260e6891d33394a2521b3a4c
Author: Hyukjin Kwon <[email protected]>
AuthorDate: Wed Jul 8 13:11:36 2026 +0900

    [SPARK-58025][INFRA] Redirect build/mvn fallback message to stderr to avoid 
corrupting version captures
    
    ### What changes were proposed in this pull request?
    
    `build/mvn`'s `install_mvn` prints `"Falling back to archive.apache.org to 
download Maven"` to **stdout** when the primary Maven mirror is unreachable, 
unlike every other diagnostic echo in the script which goes to stderr (`1>&2`). 
This redirects that message (and two adjacent error/checksum messages) to 
stderr.
    
    ### Why are the changes needed?
    
    Several scripts capture `build/mvn` stdout to read a value, e.g. 
`dev/test-dependencies.sh`:
    
    ```bash
    GUAVA_VERSION=$(build/mvn help:evaluate -Dexpression=guava.version -q 
-DforceStdout | grep -E "^[0-9.]+$")
    ```
    
    When the mirror `curl --head` check fails during the one-time Maven 
bootstrap, the fallback line lands on stdout and is captured together with (or 
instead of) the intended value. A downstream capture then resolves to the word 
`Falling`, producing failures like:
    
    ```
    [ERROR] ... The following artifacts could not be resolved:
    commons-cli:commons-cli:jar:Falling (absent): Could not find artifact
    commons-cli:commons-cli:jar:Falling in gcs-maven-central-mirror ...
    ```
    
    observed intermittently on scheduled `build_main` runs. It is intermittent 
because the fallback only triggers when the primary mirror momentarily fails 
the check. Sending the message to stderr keeps it visible in logs without 
polluting stdout captures.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No. Build-tooling only.
    
    ### How was this patch tested?
    
    Reproduced deterministically by driving `install_mvn`'s fallback branch and 
capturing stdout the way `dev/test-dependencies.sh` does.
    
    Save this as `repro.sh` (it extracts and runs the exact `Falling back...` 
echo line from a given `build/mvn`, with the mirror check forced to fail and 
the download stubbed, then captures stdout as the dependency scripts do):
    
    ```bash
    #!/bin/bash
    # Usage: repro.sh <path-to-build/mvn>
    set -euo pipefail
    MVN_FILE="$1"
    capture=$(
      fallback_line=$(grep -n 'Falling back to archive.apache.org to download 
Maven' "$MVN_FILE" | head -1 | cut -d: -f2-)
      eval "$fallback_line"      # run the exact echo from the real build/mvn
      echo "33.4.0-jre"          # stand-in for the intended stdout payload 
(e.g. a resolved version)
    )
    echo "captured = [$capture]"
    [ "$capture" = "33.4.0-jre" ] \
      && echo "RESULT: CLEAN" \
      || echo "RESULT: CORRUPTED (fallback message leaked into the capture)"
    ```
    
    Before the fix (echo on stdout):
    
    ```
    $ bash repro.sh build/mvn      # build/mvn from master
    captured = [Falling back to archive.apache.org to download Maven
    33.4.0-jre]
    RESULT: CORRUPTED (fallback message leaked into the capture)
    ```
    
    After the fix (echo redirected to stderr with `1>&2`):
    
    ```
    $ bash repro.sh build/mvn      # build/mvn from this PR
    Falling back to archive.apache.org to download Maven
    captured = [33.4.0-jre]
    RESULT: CLEAN
    ```
    
    The message still prints (now on stderr) so it remains visible in build 
logs. `bash -n build/mvn` passes.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Generated-by: Claude Code (Opus 4.8)
    
    Closes #57106 from HyukjinKwon/ci-fix/build-mvn-stdout-leak.
    
    Authored-by: Hyukjin Kwon <[email protected]>
    Signed-off-by: Hyukjin Kwon <[email protected]>
---
 build/mvn | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/build/mvn b/build/mvn
index 0afff30a7e93..74c37591a9c6 100755
--- a/build/mvn
+++ b/build/mvn
@@ -84,7 +84,7 @@ install_app() {
     fi
     # if both were unsuccessful, exit
     if [ ! -f "${local_tarball}" ]; then
-      echo -n "ERROR: Cannot download ${remote_tarball} with cURL or wget; 
please install manually and try again."
+      echo -n "ERROR: Cannot download ${remote_tarball} with cURL or wget; 
please install manually and try again." 1>&2
       exit 2
     fi
     # Checksum may not have been specified; don't check if doesn't exist
@@ -94,7 +94,7 @@ install_app() {
         # Assuming SHA512 here for now
         echo "Verifying checksum from ${local_checksum}" 1>&2
         if ! shasum -a 512 -c "${local_checksum}" > /dev/null ; then
-          echo "Bad checksum from ${remote_checksum}"
+          echo "Bad checksum from ${remote_checksum}" 1>&2
           exit 2
         fi
       fi
@@ -132,7 +132,7 @@ install_mvn() {
     if [ $(command -v curl) ]; then
       if ! curl -L --output /dev/null --silent --head --fail 
"${MIRROR_BASE%/}/${FILE_PATH}${MIRROR_URL_QUERY}" ; then
         # Fall back to archive.apache.org for older Maven
-        echo "Falling back to archive.apache.org to download Maven"
+        echo "Falling back to archive.apache.org to download Maven" 1>&2
         FILE_PATH="maven/maven-3/${MVN_VERSION}/binaries/${MVN_TARBALL}"
         MIRROR_BASE="https://archive.apache.org/dist";
         MIRROR_URL_QUERY=""


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to