[
https://issues.apache.org/jira/browse/KNOX-3246?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18055195#comment-18055195
]
ASF subversion and git services commented on KNOX-3246:
-------------------------------------------------------
Commit 60b021c9a8c4f21f363ca1651207e6c441a155e9 in knox's branch
refs/heads/master from Sandor Molnar
[ https://gitbox.apache.org/repos/asf?p=knox.git;h=60b021c9a ]
KNOX-3246 - Make Java discovery deterministic and support JDK 11/17 (#1141)
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.
> 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
> Priority: Critical
> Fix For: 3.0.0
>
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> 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:
> {code:java}
> /usr/lib/jvm/jdk1.17.0.11.0-openjdk/bin/java
> /usr/java/jdk1.11.70.15-z.0_lu/bin/java{code}
>
> or
> {code:java}
> /usr/java/jdk1.11.70.15-z.0_lu/bin/java
> /usr/lib/jvm/jdk1.17.0.11.0-openjdk/bin/java{code}
>
> 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)