Skip to content

HADOOP-15019. Honor HADOOP_USER_CLASSPATH_FIRST for deduped entries. - #8670

Open
deepujain wants to merge 1 commit into
apache:trunkfrom
deepujain:HADOOP-15019-user-classpath-first-dedupe
Open

HADOOP-15019. Honor HADOOP_USER_CLASSPATH_FIRST for deduped entries.#8670
deepujain wants to merge 1 commit into
apache:trunkfrom
deepujain:HADOOP-15019-user-classpath-first-dedupe

Conversation

@deepujain

Copy link
Copy Markdown
Contributor

Description of PR

Summary

When HADOOP_USER_CLASSPATH_FIRST=true, a user-supplied classpath entry that
is already present in Hadoop's computed classpath can stay in its older
position instead of moving to the front. This happens because duplicate
classpath entries were treated as a no-op even when they were being re-added
with before.

This patch keeps the existing de-duplication behavior, but when a duplicate
entry is re-added with before, it is moved to the front of CLASSPATH.
That preserves the expected override behavior for cases such as
HADOOP_CONF_DIR also being present in HADOOP_CLASSPATH.

Change

  • hadoop-common-project/hadoop-common/src/main/bin/hadoop-functions.sh:
    update hadoop_add_classpath() so duplicate entries are reordered to the
    front when added with before.
  • hadoop-common-project/hadoop-common/src/test/scripts/hadoop_add_classpath.bats:
    add a regression that proves a duplicate entry can be moved to the front.
  • hadoop-common-project/hadoop-common/src/test/scripts/hadoop_finalize_classpath.bats:
    add a higher-level regression that matches the JIRA scenario where
    HADOOP_CONF_DIR is duplicated in HADOOP_CLASSPATH while
    HADOOP_USER_CLASSPATH_FIRST=true.

Evidence it works

  • bash -n hadoop-common-project/hadoop-common/src/main/bin/hadoop-functions.sh
  • git diff --check
  • Direct shell validation of duplicate reordering:
    /bin/bash -lc 'set -eo pipefail; export HADOOP_SHELL_SCRIPT_DEBUG=true; export QATESTMODE=true; export HADOOP_LIBEXEC_DIR=$(cd -P hadoop-common-project/hadoop-common/src/main/bin >/dev/null && pwd -P); source hadoop-common-project/hadoop-common/src/main/bin/hadoop-functions.sh; tmpdir=$(mktemp -d); mkdir -p "$tmpdir/first" "$tmpdir/second"; CLASSPATH=""; hadoop_add_classpath "$tmpdir/first" after; hadoop_add_classpath "$tmpdir/second" after; hadoop_add_classpath "$tmpdir/second" before; test "$CLASSPATH" = "$tmpdir/second:$tmpdir/first"; rm -rf "$tmpdir"'
  • Direct shell validation of the JIRA-style finalize flow:
    /bin/bash -lc 'set -eo pipefail; export HADOOP_SHELL_SCRIPT_DEBUG=true; export QATESTMODE=true; export HADOOP_LIBEXEC_DIR=$(cd -P hadoop-common-project/hadoop-common/src/main/bin >/dev/null && pwd -P); source hadoop-common-project/hadoop-common/src/main/bin/hadoop-functions.sh; tmpdir=$(mktemp -d); mkdir -p "$tmpdir/new" "$tmpdir/old"; CLASSPATH=""; HADOOP_CONF_DIR="$tmpdir"; HADOOP_CLASSPATH="$tmpdir:$tmpdir/new:$tmpdir/old"; HADOOP_USER_CLASSPATH_FIRST=true; HADOOP_USE_CLIENT_CLASSLOADER=""; hadoop_translate_cygwin_path() { true; }; hadoop_finalize_classpath; test "$CLASSPATH" = "$tmpdir:$tmpdir/new:$tmpdir/old"; rm -rf "$tmpdir"'
  • bats is not installed in this local environment, so the new .bats
    regressions were validated through the equivalent sourced-function shell
    invocations above.

JIRA

Fixes HADOOP-15019

For code changes:

  • Does the title of this PR start with the corresponding JIRA issue id
    (e.g. 'HADOOP-17799. Your PR title ...')?
  • Object storage: Have the integration tests been executed and the endpoint
    declared according to the connector-specific documentation? Not
    applicable to this shell-script change.
  • If adding new dependencies to the code, are these dependencies licensed
    in a way that is compatible for inclusion under
    ASF 2.0?
    No new dependencies are added.
  • If applicable, have you updated the LICENSE, LICENSE-binary,
    NOTICE-binary files? No license or notice changes are required.

AI Tooling

Contains content generated by Codex.

If an AI tool was used:

@hadoop-yetus

Copy link
Copy Markdown

🎊 +1 overall

VoteSubsystemRuntimeLogfileComment
+0 🆗reexec0m 35sDocker mode activated.
_ Prechecks _
+1 💚dupname0m 0sNo case conflicting files found.
+0 🆗codespell0m 0scodespell was not available.
+0 🆗detsecrets0m 0sdetect-secrets was not available.
+0 🆗shelldocs0m 0sShelldocs was not available.
+1 💚@author0m 0sThe patch does not contain any @author tags.
+1 💚test4tests0m 0sThe patch appears to include 2 new or modified test files.
_ trunk Compile Tests _
+1 💚mvninstall44m 43strunk passed
+1 💚mvnsite1m 57strunk passed
+1 💚shadedclient27m 43sbranch has no errors when building and testing our client artifacts.
_ Patch Compile Tests _
+1 💚mvninstall1m 12sthe patch passed
+1 💚blanks0m 0sThe patch has no blanks issues.
+1 💚mvnsite1m 25sthe patch passed
+1 💚shellcheck0m 4sNo new issues.
+1 💚shadedclient27m 0spatch has no errors when building and testing our client artifacts.
_ Other Tests _
+1 💚unit1m 53shadoop-common in the patch passed.
+1 💚asflicense0m 35sThe patch does not generate ASF License warnings.
109m 52s
SubsystemReport/Notes
DockerClientAPI=1.55 ServerAPI=1.55 base: https://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8670/1/artifact/out/Dockerfile
GITHUB PR#8670
Optional Testsdupname asflicense mvnsite unit codespell detsecrets shellcheck shelldocs
unameLinux 6ca4040a72f8 5.15.0-186-generic #196-Ubuntu SMP Sat Jun 20 16:09:34 UTC 2026 x86_64 x86_64 x86_64 GNU/Linux
Build toolmaven
Personalitydev-support/bin/hadoop.sh
git revisiontrunk / fb10cf8
Test Resultshttps://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8670/1/testReport/
Max. process+thread count615 (vs. ulimit of 10000)
modulesC: hadoop-common-project/hadoop-common U: hadoop-common-project/hadoop-common
Console outputhttps://ci-hadoop.apache.org/job/hadoop-multibranch/job/PR-8670/1/console
versionsgit=2.43.0 maven=3.9.15 shellcheck=0.9.0
Powered byApache Yetus 0.14.1 https://yetus.apache.org

This message was automatically generated.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@deepujain@hadoop-yetus