You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@knox.apache.org by "Sandor Molnar (Jira)" <ji...@apache.org> on 2026/01/29 10:33:00 UTC

[jira] [Created] (KNOX-3246) Make Java discovery deterministic on hosts with multiple JDKs

Sandor Molnar created KNOX-3246:
-----------------------------------

             Summary: Make Java discovery deterministic on hosts with multiple JDKs
                 Key: KNOX-3246
                 URL: https://issues.apache.org/jira/browse/KNOX-3246
             Project: Apache Knox
          Issue Type: Improvement
          Components: Startup Scripts
    Affects Versions: 2.1.0, 3.0.0
            Reporter: Sandor Molnar
            Assignee: Sandor Molnar
             Fix For: 3.0.0


h3. *Problem*

Knox Java discovery is non-deterministic on hosts with multiple JDK installations.

In environments where both Java 11 and Java 17 are installed, neither version is matched by the current {{{}JAVA_VERSION_PATTERNS{}}}. As a result, Java detection falls back to the generic {{/bin/java$}} pattern and selects the first match returned by {{{}find{}}}.

Because the order of results from {{find}} is not guaranteed, different hosts in the same cluster may select different Java versions, leading to inconsistent and unpredictable behavior.
----
h3. *Root Cause*
 * {{JAVA_VERSION_PATTERNS}} does not include patterns for Java 11 or Java 17 installations.

 * {{{}/usr/java/default/bin/java{}}}, commonly used to define the system-preferred Java, is not recognized.

 * {{find}} is executed without {{{}-L{}}}, so symlinks are not followed.

 * The fallback selection uses {{head -n 1}} without stabilizing the result order.

----
h3. *Example*

On different hosts in the same cluster:
/usr/lib/jvm/jdk1.17.0.11.0-openjdk/bin/java
/usr/java/jdk1.11.70.15-z.0_lu/bin/java
 
or
/usr/java/jdk1.11.70.15-z.0_lu/bin/java
/usr/lib/jvm/jdk1.17.0.11.0-openjdk/bin/java
 
Depending on the host, Knox may start with Java 11 or Java 17.
----
h3. *Proposed Fix*
 * Extend {{JAVA_VERSION_PATTERNS}} to explicitly recognize Java 11 and Java 17 layouts.

 * Add support for {{/usr/java/default/bin/java}} to honor the system default Java.

 * Use {{find -L}} to follow symlinks.

 * Sort Java candidates before selecting the first match to ensure deterministic behavior.

----
h3. *Impact*

Ensures consistent Java version selection across all nodes in a cluster, prevents unpredictable startup behavior, and aligns Knox Java discovery with common enterprise JDK layouts.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)