Skip to content

Commit

Permalink
[fix][env]Fix potential incompatible java opts caused by IS_JAVA_8 (a…
Browse files Browse the repository at this point in the history
…pache#15444)

* Fix potential incompatible java opts caused by IS_JAVA_8

* apply reviews

Co-authored-by: gavingaozhangmin <[email protected]>
  • Loading branch information
gaozhangmin and gavingaozhangmin authored May 6, 2022
1 parent 8be657a commit acccfa9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion bin/bookkeeper
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ OPTS="$OPTS -Dlog4j.configurationFile=`basename $BOOKIE_LOG_CONF`"
# Allow Netty to use reflection access
OPTS="$OPTS -Dio.netty.tryReflectionSetAccessible=true"

IS_JAVA_8=`java -version 2>&1 |grep version|grep '"1\.8'`
IS_JAVA_8=`$JAVA -version 2>&1 |grep version|grep '"1\.8'`
# Start --add-opens options
# '--add-opens' option is not supported in jdk8
if [[ -z "$IS_JAVA_8" ]]; then
Expand Down
24 changes: 12 additions & 12 deletions bin/function-localrunner
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,24 @@ export PULSAR_HOME=`cd -P $BINDIR/..;pwd`

DEFAULT_LOG_CONF=$PULSAR_HOME/conf/log4j2.yaml

# Check for the java to use
if [[ -z $JAVA_HOME ]]; then
JAVA=$(which java)
if [ $? != 0 ]; then
echo "Error: JAVA_HOME not set, and no java executable found in $PATH." 1>&2
exit 1
fi
else
JAVA=$JAVA_HOME/bin/java
fi

PULSAR_MEM=${PULSAR_MEM:-"-Xmx128m -XX:MaxDirectMemorySize=128m"}

# Garbage collection options
PULSAR_GC=${PULSAR_GC:-"-XX:+UseG1GC -XX:MaxGCPauseMillis=10 -XX:+ParallelRefProcEnabled -XX:+UnlockExperimentalVMOptions -XX:+DoEscapeAnalysis -XX:G1NewSizePercent=50 -XX:+DisableExplicitGC"}

# Garbage collection log.
IS_JAVA_8=`java -version 2>&1 |grep version|grep '"1\.8'`
IS_JAVA_8=`$JAVA -version 2>&1 |grep version|grep '"1\.8'`
# java version has space, use [[ -n $PARAM ]] to judge if variable exists
if [[ -n "$IS_JAVA_8" ]]; then
PULSAR_GC_LOG=${PULSAR_GC_LOG:-"-Xloggc:logs/pulsar_gc_%p.log -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=20M"}
Expand All @@ -41,17 +52,6 @@ fi
# Extra options to be passed to the jvm
PULSAR_EXTRA_OPTS=${PULSAR_EXTRA_OPTS:-" -Dpulsar.allocator.exit_on_oom=true -Dio.netty.recycler.maxCapacityPerThread=4096"}

# Check for the java to use
if [[ -z $JAVA_HOME ]]; then
JAVA=$(which java)
if [ $? != 0 ]; then
echo "Error: JAVA_HOME not set, and no java executable found in $PATH." 1>&2
exit 1
fi
else
JAVA=$JAVA_HOME/bin/java
fi

if [ -z "$PULSAR_LOG_CONF" ]; then
PULSAR_LOG_CONF=$DEFAULT_LOG_CONF
fi
Expand Down
2 changes: 1 addition & 1 deletion bin/pulsar
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ OPTS="$OPTS -Djute.maxbuffer=10485760 -Djava.net.preferIPv4Stack=true"

# Allow Netty to use reflection access
OPTS="$OPTS -Dio.netty.tryReflectionSetAccessible=true"
IS_JAVA_8=`java -version 2>&1 |grep version|grep '"1\.8'`
IS_JAVA_8=`$JAVA -version 2>&1 |grep version|grep '"1\.8'`
# Start --add-opens options
# '--add-opens' option is not supported in jdk8
if [[ -z "$IS_JAVA_8" ]]; then
Expand Down

0 comments on commit acccfa9

Please sign in to comment.