Skip to content

Conversation

@smolnar82
Copy link
Contributor

KNOX-3246 - Make Java discovery deterministic on hosts with multiple JDKs

What changes were proposed in this pull request?

Extend JAVA_VERSION_PATTERNS to include modern JDK layouts and /usr/java/default. Follow symlinks during discovery and sort candidates to ensure deterministic Java selection on hosts with multiple JDKs installed.

How was this patch tested?

Tested on my cluster with mixed JDK versions.

$ cat smolnar_test.sh 

#!/usr/bin/env bash

. /$KNOX_HOME/bin/knox-functions.sh

setVerbose "$@"
checkJava

Prior to my changes:

$ ./smolnar_test.sh --verbose
Found Java at /usr/java/jdk1.11.70.15-z.0_lu/bin/java

My changes included:

$ ./smolnar_test.sh --verbose
Found Java at /usr/java/default/bin/java

$ /usr/java/default/bin/java -version
openjdk version "17.0.11" 2024-04-16
OpenJDK Runtime Environment OpenLogic-OpenJDK (build 17.0.11+9-adhoc.root.jdk17u)
OpenJDK 64-Bit Server VM OpenLogic-OpenJDK (build 17.0.11+9-adhoc.root.jdk17u, mixed mode, sharing)

Integration Tests

This issue is hard to reproduce in the existing docker-based framework. It requires a multi JDK setup which usually happens at cluster upgrade time.

UI changes

None

Extend JAVA_VERSION_PATTERNS to include modern JDK layouts and
/usr/java/default. Follow symlinks during discovery and sort
candidates to ensure deterministic Java selection on hosts with
multiple JDKs installed.
@smolnar82 smolnar82 self-assigned this Jan 29, 2026
@smolnar82 smolnar82 added the bash label Jan 29, 2026
@github-actions
Copy link

Test Results

7 tests   7 ✅  1s ⏱️
1 suites  0 💤
1 files    0 ❌

Results for commit 95c97fc.

@smolnar82 smolnar82 merged commit 60b021c into apache:master Jan 29, 2026
3 checks passed
Sign up for free to 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.

3 participants