ekaterinadimitrova2 commented on code in PR #2563:
URL: https://github.com/apache/cassandra/pull/2563#discussion_r1414434123


##########
bin/cassandra.in.sh:
##########
@@ -116,19 +116,34 @@ if [ -z $JAVA ] ; then
     exit 1;
 fi
 
+# Matches variable 'java.supported' in build.xml
+java_versions_supported=11,17
+
 # 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)
 
-JAVA_VERSION=17
-if [ "$short" = "11" ]  ; then
-     JAVA_VERSION=11
-elif [ "$JVM_VERSION" \< "17" ] ; then
-    echo "Cassandra 5.0 requires Java 11 or Java 17."
+# 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
+supported_version=$(echo "$java_versions_supported" | tr "," '\n' | grep -F -x 
"$short")
+if [ -z "$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=true"
+        exit 1;
+    else
+        echo 
"######################################################################"
+        echo "Warning! You are using JDK$short. Cassandra currently only 
supports $java_versions_supported."

Review Comment:
   nit: `Warning! You are using JDK$short. This Cassandra version only supports 
$java_versions_supported.`
   
   
   If we do not want to pull/hardcore the version of Cassandra we can just 
stress on `this version`
   I hear many times people ask about JDK version and assume that it will be 
added for all versions, so it is good to stress on "this version" in my opinion



##########
bin/cassandra.in.sh:
##########
@@ -116,19 +116,34 @@ if [ -z $JAVA ] ; then
     exit 1;
 fi
 
+# Matches variable 'java.supported' in build.xml
+java_versions_supported=11,17
+
 # 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)
 
-JAVA_VERSION=17
-if [ "$short" = "11" ]  ; then
-     JAVA_VERSION=11
-elif [ "$JVM_VERSION" \< "17" ] ; then
-    echo "Cassandra 5.0 requires Java 11 or Java 17."
+# 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
+supported_version=$(echo "$java_versions_supported" | tr "," '\n' | grep -F -x 
"$short")
+if [ -z "$supported_version" ] ; then

Review Comment:
   nit: `supported_versions`



##########
tools/bin/cassandra.in.sh:
##########
@@ -76,18 +76,35 @@ if [ -z $JAVA ] ; then
     exit 1;
 fi
 
+# Matches variable 'java.supported' in build.xml
+java_versions_supported=11,17
+
 # 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)
 
-JAVA_VERSION=17
-if [ "$short" = "11" ] ; then
-     JAVA_VERSION=11
-elif [ "$JVM_VERSION" \< "17" ] ; then
-    echo "Cassandra 5.0 requires Java 11 or Java 17(or newer)."
+# 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
+supported_version=$(echo "$java_versions_supported" | tr "," '\n' | grep -F -x 
"$short")
+if [ -z "$supported_version" ] ; then
+    if [ -z "$CASSANDRA_JDK_UNSUPPORTED" ] ; then

Review Comment:
   This comment is valid for all places where this check occurs



##########
redhat/cassandra.in.sh:
##########
@@ -74,19 +74,34 @@ if [ -z $JAVA ] ; then
     exit 1;
 fi
 
+# Matches variable 'java.supported' in build.xml
+java_versions_supported=11,17
+
 # 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)
 
-JAVA_VERSION=17
-if [ "$short" = "11" ]  ; then
-     JAVA_VERSION=11
-elif [ "$JVM_VERSION" \< "17" ] ; then
-    echo "Cassandra 5.0 requires Java 11 or Java 17."
+# 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
+supported_version=$(echo "$java_versions_supported" | tr "," '\n' | grep -F -x 
"$short")
+if [ -z "$supported_version" ] ; then

Review Comment:
   nit:`supported_versions`



##########
tools/bin/cassandra.in.sh:
##########
@@ -76,18 +76,35 @@ if [ -z $JAVA ] ; then
     exit 1;
 fi
 
+# Matches variable 'java.supported' in build.xml
+java_versions_supported=11,17
+
 # 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)
 
-JAVA_VERSION=17
-if [ "$short" = "11" ] ; then
-     JAVA_VERSION=11
-elif [ "$JVM_VERSION" \< "17" ] ; then
-    echo "Cassandra 5.0 requires Java 11 or Java 17(or newer)."
+# 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
+supported_version=$(echo "$java_versions_supported" | tr "," '\n' | grep -F -x 
"$short")
+if [ -z "$supported_version" ] ; then
+    if [ -z "$CASSANDRA_JDK_UNSUPPORTED" ] ; then

Review Comment:
   ```suggestion
      if [ -z "$CASSANDRA_JDK_UNSUPPORTED" ] || [ "$CASSANDRA_JDK_UNSUPPORTED" 
= "false" ] ; then
   ```
   
   Otherwise I can set it to false and it still accepts JDK21 which is weird



-- 
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