drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [1/3] drill git commit: DRILL-5208: Finding path to java executable should be deterministic
Date Fri, 03 Mar 2017 22:10:21 GMT
Repository: drill
Updated Branches:
  refs/heads/master 7ebb985ed -> 3dfb49729


DRILL-5208: Finding path to java executable should be deterministic

See DRILL-5208 for background. Instead of using “find” to locate the
java command, we use the any information available, resorting to find
only if the “usual suspects” fails. The result is that we use the JDK
java when available, instead of randomly choosing JDK or JRE java.

close #763


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/d96914f1
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/d96914f1
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/d96914f1

Branch: refs/heads/master
Commit: d96914f161e241902b0d3c204164cedc97471d12
Parents: 7ebb985
Author: Paul Rogers <progers@maprtech.com>
Authored: Fri Feb 24 14:53:23 2017 -0800
Committer: Jinfeng Ni <jni@apache.org>
Committed: Thu Mar 2 23:12:45 2017 -0800

----------------------------------------------------------------------
 distribution/src/resources/drill-config.sh | 28 ++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/d96914f1/distribution/src/resources/drill-config.sh
----------------------------------------------------------------------
diff --git a/distribution/src/resources/drill-config.sh b/distribution/src/resources/drill-config.sh
index ed03b28..1946275 100644
--- a/distribution/src/resources/drill-config.sh
+++ b/distribution/src/resources/drill-config.sh
@@ -347,10 +347,17 @@ case "`uname`" in
 CYGWIN*) is_cygwin=true;;
 esac
 
+if $is_cygwin; then
+  JAVA_BIN="java.exe"
+else
+  JAVA_BIN="java"
+fi
+
 # Test for or find JAVA_HOME
+
 if [ -z "$JAVA_HOME" ]; then
-  if [ -e `which java` ]; then
-    SOURCE=`which java`
+  SOURCE=`which java`
+  if [ -e $SOURCE ]; then
     while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
       DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
       SOURCE="$(readlink "$SOURCE")"
@@ -359,6 +366,7 @@ if [ -z "$JAVA_HOME" ]; then
       [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
     done
     JAVA_HOME="$( cd -P "$( dirname "$SOURCE" )" && cd .. && pwd )"
+    JAVA=$SOURCE
   fi
   # if we didn't set it
   if [ -z "$JAVA_HOME" ]; then
@@ -367,12 +375,18 @@ if [ -z "$JAVA_HOME" ]; then
 fi
 
 # Now, verify that 'java' binary exists and is suitable for Drill.
-if $is_cygwin; then
-  JAVA_BIN="java.exe"
-else
-  JAVA_BIN="java"
+# If we started with `which java` above, use that path (after replacing
+# symlinks.) If we started with JAVA_HOME, try in bin. Doing so handles
+# the case in which JAVA_HOME is a JDK that has a nested JRE; we prefer
+# the JDK bin. Finally, if nothing else works, just search for the
+# executable.
+
+if [ -z "$JAVA" ]; then
+  JAVA="$JAVA_HOME/bin/$JAVA_BIN"
+  if [[ ! -e $JAVA ]]; then
+    JAVA=`find -L "$JAVA_HOME" -name $JAVA_BIN -type f | head -n 1`
+  fi
 fi
-JAVA=`find -L "$JAVA_HOME" -name $JAVA_BIN -type f | head -n 1`
 if [ ! -e "$JAVA" ]; then
   fatal_error "Java not found at JAVA_HOME=$JAVA_HOME."
 fi


Mime
View raw message