This is an automated email from the ASF dual-hosted git repository.
HyukjinKwon pushed a commit to branch branch-3.5
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-3.5 by this push:
new e2680291a798 [SPARK-58025][INFRA] Redirect build/mvn fallback message
to stderr to avoid corrupting version captures
e2680291a798 is described below
commit e2680291a79896769aacaf517dc1d4a1bfc8776c
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
`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.
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.
No. Build-tooling only.
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
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.
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]>
(cherry picked from commit 421067d264f39159260e6891d33394a2521b3a4c)
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 2c778fd6c71a..65870a579685 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
@@ -128,7 +128,7 @@ install_mvn() {
if [ $(command -v curl) ]; then
if ! curl -L --output /dev/null --silent --head --fail
"${APACHE_MIRROR}/${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
APACHE_MIRROR="https://archive.apache.org/dist"
MIRROR_URL_QUERY=""
fi
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]