Skip to content

Commit 14224cf

Browse files
committed
KNOX-3210 - Use a common function to set JDK17 properties across all scripts
1 parent 7ecd609 commit 14224cf

2 files changed

Lines changed: 12 additions & 14 deletions

File tree

gateway-release-common/home/bin/knox-functions.sh

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,16 @@ function addAppJavaOpts {
159159
done
160160
}
161161

162+
function addJdk17Properties {
163+
# Add properties to enable Knox to run on JDK 17
164+
JAVA_VERSION=$("$JAVA" -version 2>&1 | awk -F '"' '/version/ {print $2}')
165+
CHECK_VERSION_17="17"
166+
if [[ "$JAVA_VERSION" == *"$CHECK_VERSION_17"* ]]; then
167+
echo "Java version is $CHECK_VERSION_17. Adding properties to enable Knox to run on JDK 17"
168+
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"
169+
fi
170+
}
171+
162172
function buildAppJavaOpts {
163173
if [ -n "$APP_MEM_OPTS" ]; then
164174
addAppJavaOpts "${APP_MEM_OPTS}"
@@ -176,13 +186,7 @@ function buildAppJavaOpts {
176186
addAppJavaOpts "${APP_JAVA_LIB_PATH}"
177187
fi
178188

179-
# Add properties to enable Knox to run on JDK 17
180-
JAVA_VERSION=$("$JAVA" -version 2>&1 | awk -F '"' '/version/ {print $2}')
181-
CHECK_VERSION_17="17"
182-
if [[ "$JAVA_VERSION" == *"$CHECK_VERSION_17"* ]]; then
183-
echo "Java version is $CHECK_VERSION_17. Adding properties to enable Knox to run on JDK 17"
184-
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"
185-
fi
189+
addJdk17Properties
186190

187191
# echo "APP_JAVA_OPTS =" "${APP_JAVA_OPTS[@]}"
188192
}

gateway-release/home/bin/knoxcli.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,7 @@ function buildAppJavaOpts {
6262
addAppJavaOpts "${APP_JAVA_LIB_PATH}"
6363
fi
6464

65-
# Add properties to enable Knox to run on JDK 17
66-
JAVA_VERSION=$("$JAVA" -version 2>&1 | awk -F '"' '/version/ {print $2}')
67-
CHECK_VERSION_17="17"
68-
if [[ "$JAVA_VERSION" == *"$CHECK_VERSION_17"* ]]; then
69-
echo "Java version is $CHECK_VERSION_17. Adding properties to enable Knox to run on JDK 17"
70-
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"
71-
fi
65+
addJdk17Properties
7266

7367
# echo "APP_JAVA_OPTS =" "${APP_JAVA_OPTS[@]}"
7468
}

0 commit comments

Comments
 (0)