[ 
https://issues.apache.org/jira/browse/CASSANDRA-21703?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Michael Semb Wever updated CASSANDRA-21703:
-------------------------------------------
     Bug Category: Parent values: Code(13163)
       Complexity: Low Hanging Fruit
    Discovered By: Code Inspection
    Fix Version/s: 6.0.x
                   7.x
         Severity: Normal
           Status: Open  (was: Triage Needed)

> The startup scripts read the JDK version from PATH rather than from JAVA_HOME
> -----------------------------------------------------------------------------
>
>                 Key: CASSANDRA-21703
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-21703
>             Project: Apache Cassandra
>          Issue Type: Bug
>          Components: Local/Scripts
>            Reporter: Michael Semb Wever
>            Priority: Normal
>             Fix For: 6.0.x, 7.x
>
>
> {{bin/cassandra.in.sh}} and {{tools/bin/cassandra.in.sh}} resolve {{$JAVA}} 
> from {{JAVA_HOME}}, and then read the version by running the bare {{java}} 
> found on {{PATH}}:
> {code:none}
> if [ -n "$JAVA_HOME" ]; then
>     for java in "$JAVA_HOME"/bin/amd64/java "$JAVA_HOME"/bin/java; do
>         if [ -x "$java" ]; then
>             JAVA="$java"
>             break
>         fi
>     done
> else
>     JAVA=`command -v java 2> /dev/null`
> fi
> ...
> JAVA_VERSION=$(java -version 2>&1 | grep '[openjdk|java] version' | cut -d 
> '"' -f2 | cut -d '.' -f1)
> {code}
> When {{JAVA_HOME}} and {{PATH}} name different JDKs, {{JAVA_VERSION}} 
> describes a JVM that never runs, and two failures follow.
> The version gate then judges the wrong JVM. It refuses a supported JDK, or 
> admits an unsupported one, and {{JVM_DEP_OPTS_FILE}} loads the 
> {{jvm<N>-server.options}} file for the version it read. A node started with a 
> JDK 21 {{JAVA_HOME}} and JDK 17 on {{PATH}} runs JDK 21 and reads 
> {{jvm17-server.options}}.
> When {{JAVA_HOME}} is set and {{PATH}} holds no {{java}} at all, 
> {{JAVA_VERSION}} is empty. The comparison loop reports {{[: : integer 
> expression expected}} three times, and the gate exits with {{Unsupported Java 
> .}}, though {{$JAVA}} names a supported JDK.
> The patch reads {{"$JAVA"}} in both files. The block above it exits when 
> {{$JAVA}} is empty, so no fallback is needed. {{USING_JDK}} on the lines 
> below is left alone: it looks for {{javac}} rather than {{java}}, and prefers 
> {{PATH}} deliberately.
> CASSANDRA-18831 introduced the bare call, when it replaced the 
> {{java_ver_output}} block that had read {{$JAVA}}. {{cassandra-5.0}} still 
> reads {{$JAVA}} and is unaffected, so {{cassandra-6.0}} is the oldest 
> affected branch.
> Patch: 
> [mck/upstream/jdk-gate-ignores-java-home/6.0|https://github.com/thelastpickle/cassandra/tree/mck/upstream/jdk-gate-ignores-java-home/6.0]
> Provenance: 
> [3927744acf|https://github.com/datastax/cassandra/commit/3927744acf9023a05340bdc198c89c3f4d6e0949]
>  by [~mck], in 
> [datastax/cassandra#2193|https://github.com/datastax/cassandra/pull/2193]. 
> That pull request rewrites the whole gate on the fork's {{main-5.0}} branch, 
> adds JDK 22 to it, and carries fork-only packaging work beside it. This patch 
> takes only the one correction that applies upstream.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to