From 4d8f848fb62de2c5dca4ed378f39a99bb38a11ce Mon Sep 17 00:00:00 2001 From: Ismael Juma Date: Wed, 18 Apr 2018 16:06:44 -0700 Subject: [PATCH 1/2] MINOR: Fix kafka-run-class for Java 10 --- bin/kafka-run-class.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/kafka-run-class.sh b/bin/kafka-run-class.sh index 4dd092323b043..49d2e95b3a394 100755 --- a/bin/kafka-run-class.sh +++ b/bin/kafka-run-class.sh @@ -270,7 +270,7 @@ if [ "x$GC_LOG_ENABLED" = "xtrue" ]; then GC_LOG_FILE_NAME=$DAEMON_NAME$GC_FILE_SUFFIX # the first segment of the version number, which is '1' for releases before Java 9 # it then becomes '9', '10', ... - JAVA_MAJOR_VERSION=$($JAVA -version 2>&1 | sed -E -n 's/.* version "([^.-]*).*"/\1/p') + JAVA_MAJOR_VERSION=$($JAVA -version 2>&1 | sed -E -n 's/.* version "([0-9]*).*$/\1/p') if [[ "$JAVA_MAJOR_VERSION" -ge "9" ]] ; then KAFKA_GC_LOG_OPTS="-Xlog:gc*:file=$LOG_DIR/$GC_LOG_FILE_NAME:time,tags:filecount=10,filesize=102400" else From 95f0f3e0e9c5bd39553ddd1dfeecb7da2337e494 Mon Sep 17 00:00:00 2001 From: Ismael Juma Date: Wed, 18 Apr 2018 16:21:36 -0700 Subject: [PATCH 2/2] Improve comment --- bin/kafka-run-class.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/kafka-run-class.sh b/bin/kafka-run-class.sh index 49d2e95b3a394..7a0a92ad41489 100755 --- a/bin/kafka-run-class.sh +++ b/bin/kafka-run-class.sh @@ -268,8 +268,15 @@ GC_FILE_SUFFIX='-gc.log' GC_LOG_FILE_NAME='' if [ "x$GC_LOG_ENABLED" = "xtrue" ]; then GC_LOG_FILE_NAME=$DAEMON_NAME$GC_FILE_SUFFIX - # the first segment of the version number, which is '1' for releases before Java 9 + + # The first segment of the version number, which is '1' for releases before Java 9 # it then becomes '9', '10', ... + # Some examples of the first line of `java --version`: + # 8 -> java version "1.8.0_152" + # 9.0.4 -> java version "9.0.4" + # 10 -> java version "10" 2018-03-20 + # 10.0.1 -> java version "10.0.1" 2018-04-17 + # We need to match to the end of the line to prevent sed from printing the characters that do not match JAVA_MAJOR_VERSION=$($JAVA -version 2>&1 | sed -E -n 's/.* version "([0-9]*).*$/\1/p') if [[ "$JAVA_MAJOR_VERSION" -ge "9" ]] ; then KAFKA_GC_LOG_OPTS="-Xlog:gc*:file=$LOG_DIR/$GC_LOG_FILE_NAME:time,tags:filecount=10,filesize=102400"