michaelsembwever commented on code in PR #3696:
URL: https://github.com/apache/cassandra/pull/3696#discussion_r2725806324


##########
redhat/cassandra.in.sh:
##########
@@ -121,46 +121,46 @@ if [ -z $JAVA ] ; then
     exit 1;
 fi
 
+# TODO: Factor this out to something we source so we don't have the 
duplication all over our scripts
 # Matches variable 'java.supported' in build.xml
-java_versions_supported=11,17
+java_versions_supported=(11 17 21)
+java_version_string=$(IFS=" "; echo "${java_versions_supported[*]}")
 
 # Determine the sort of JVM we'll be running on.
-java_ver_output=`"${JAVA:-java}" -version 2>&1`
-jvmver=`echo "$java_ver_output" | grep '[openjdk|java] version' | awk -F'"' 
'NR==1 {print $2}' | cut -d\- -f1`
-JVM_VERSION=${jvmver%_*}
-short=$(echo "${jvmver}" | cut -c1-2)
-
-# Unsupported JDKs below the upper supported version are not allowed
-if [ "$short" != "$(echo "$java_versions_supported" | cut -d, -f1)" ] && [ 
"$JVM_VERSION" \< "$(echo "$java_versions_supported" | cut -d, -f2)" ] ; then
-    echo "Unsupported Java $JVM_VERSION. Supported are 
$java_versions_supported"
-    exit 1;
-fi
-# Allow execution of supported Java versions, and newer if 
CASSANDRA_JDK_UNSUPPORTED is set
-is_supported_version=$(echo "$java_versions_supported" | tr "," '\n' | grep -F 
-x "$short")
-if [ -z "$is_supported_version" ] ; then
-    if [ -z "$CASSANDRA_JDK_UNSUPPORTED" ] ; then
-        echo "Unsupported Java $JVM_VERSION. Supported are 
$java_versions_supported"
-        echo "If you would like to test with newer Java versions set 
CASSANDRA_JDK_UNSUPPORTED to any value (for example, 
CASSANDRA_JDK_UNSUPPORTED=true). Unset the parameter for default behavior"
-        exit 1;
-    else
-        echo 
"######################################################################"
-        echo "Warning! You are using JDK$short. This Cassandra version only 
supports $java_versions_supported."
-        echo 
"######################################################################"
-    fi
+JAVA_VERSION=$(java -version 2>&1 | grep '[openjdk|java] version' | cut -d '"' 
-f2 | cut -d '.' -f1)
+
+supported=0
+for version in "${java_versions_supported[@]}"; do
+  if [ "$version" -eq "$JAVA_VERSION" ]; then
+      supported=1
+  fi
+done
+
+if [[ "$supported" -eq 0 ]]; then
+  if [ -z "$CASSANDRA_JDK_UNSUPPORTED" ]; then
+    echo "Unsupported Java $JAVA_VERSION. Supported are $java_version_string"
+    echo "If you would like to test with newer Java versions set 
CASSANDRA_JDK_UNSUPPORTED to any value (for example, 
CASSANDRA_JDK_UNSUPPORTED=true). Unset the parameter for default behavior"
+    exit 1
+  else
+    echo 
"######################################################################"
+    echo "Warning! You are using JDK$JAVA_VERSION. This Cassandra version only 
supports $java_version_string"
+    echo 
"######################################################################"
+  fi
 fi
-JAVA_VERSION=$short
 
-jvm=`echo "$java_ver_output" | grep -A 1 '[openjdk|java] version' | awk 'NR==2 
{print $1}'`
+# TODO: Either remove the JVM_VENDOR and JVM_ARCH variables or explain where 
they're used. Appear vestigial.

Review Comment:
   same comment as in `bin/cassandra.in.sh`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to