KNOX-3210 - Use a common function to set JDK17 properties across all scripts (#1102)
diff --git a/gateway-release-common/home/bin/knox-functions.sh b/gateway-release-common/home/bin/knox-functions.sh
index c54ebbd..7cea1c5 100644
--- a/gateway-release-common/home/bin/knox-functions.sh
+++ b/gateway-release-common/home/bin/knox-functions.sh
@@ -159,6 +159,16 @@
done
}
+function addJdk17Properties {
+ # Add properties to enable Knox to run on JDK 17
+ JAVA_VERSION=$("$JAVA" -version 2>&1 | awk -F '"' '/version/ {print $2}')
+ CHECK_VERSION_17="17"
+ if [[ "$JAVA_VERSION" == *"$CHECK_VERSION_17"* ]]; then
+ echo "Java version is $CHECK_VERSION_17. Adding properties to enable Knox to run on JDK 17"
+ addAppJavaOpts " --add-exports java.base/sun.security.x509=ALL-UNNAMED --add-exports java.base/sun.security.pkcs=ALL-UNNAMED --add-exports java.naming/com.sun.jndi.ldap=ALL-UNNAMED --add-opens java.base/sun.security.util=ALL-UNNAMED --add-exports java.base/jdk.internal.misc=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-exports java.base/sun.net.util=ALL-UNNAMED --add-exports java.base/sun.net.dns=ALL-UNNAMED"
+ fi
+}
+
function buildAppJavaOpts {
if [ -n "$APP_MEM_OPTS" ]; then
addAppJavaOpts "${APP_MEM_OPTS}"
@@ -176,13 +186,7 @@
addAppJavaOpts "${APP_JAVA_LIB_PATH}"
fi
- # Add properties to enable Knox to run on JDK 17
- JAVA_VERSION=$("$JAVA" -version 2>&1 | awk -F '"' '/version/ {print $2}')
- CHECK_VERSION_17="17"
- if [[ "$JAVA_VERSION" == *"$CHECK_VERSION_17"* ]]; then
- echo "Java version is $CHECK_VERSION_17. Adding properties to enable Knox to run on JDK 17"
- addAppJavaOpts " --add-exports java.base/sun.security.x509=ALL-UNNAMED --add-exports java.base/sun.security.pkcs=ALL-UNNAMED --add-exports java.naming/com.sun.jndi.ldap=ALL-UNNAMED --add-opens java.base/sun.security.util=ALL-UNNAMED --add-exports java.base/jdk.internal.misc=ALL-UNNAMED --add-opens=java.base/java.lang=ALL-UNNAMED --add-exports java.base/sun.net.util=ALL-UNNAMED --add-exports java.base/sun.net.dns=ALL-UNNAMED"
- fi
+ addJdk17Properties
# echo "APP_JAVA_OPTS =" "${APP_JAVA_OPTS[@]}"
}
diff --git a/gateway-release/home/bin/knoxcli.sh b/gateway-release/home/bin/knoxcli.sh
index a1569d7..4d5e0a9 100755
--- a/gateway-release/home/bin/knoxcli.sh
+++ b/gateway-release/home/bin/knoxcli.sh
@@ -62,13 +62,7 @@
addAppJavaOpts "${APP_JAVA_LIB_PATH}"
fi
- # Add properties to enable Knox to run on JDK 17
- JAVA_VERSION=$("$JAVA" -version 2>&1 | awk -F '"' '/version/ {print $2}')
- CHECK_VERSION_17="17"
- if [[ "$JAVA_VERSION" == *"$CHECK_VERSION_17"* ]]; then
- echo "Java version is $CHECK_VERSION_17. Adding properties to enable Knox to run on JDK 17"
- addAppJavaOpts " --add-exports java.base/sun.security.x509=ALL-UNNAMED --add-exports java.base/sun.security.pkcs=ALL-UNNAMED --add-exports java.naming/com.sun.jndi.ldap=ALL-UNNAMED --add-opens java.base/sun.security.util=ALL-UNNAMED"
- fi
+ addJdk17Properties
# echo "APP_JAVA_OPTS =" "${APP_JAVA_OPTS[@]}"
}