From 23dae5f81d0349d492a2e808f3ca8a8c82bcb6e1 Mon Sep 17 00:00:00 2001
From: Ludovic Poitou <ludovic.poitou@forgerock.com>
Date: Thu, 07 Feb 2013 12:09:26 +0000
Subject: [PATCH] Fix issue OPENDJ-732: Both start-ds and set-java-home were missing quotes around variables, and failed if the Java path contains spaces (like with QuickSetup on Mac OSX, which uses the Plugin JRE).

---
 opends/src/server/org/opends/server/tools/JavaPropertiesTool.java |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/opends/src/server/org/opends/server/tools/JavaPropertiesTool.java b/opends/src/server/org/opends/server/tools/JavaPropertiesTool.java
index ce8700f..d9a0e18 100644
--- a/opends/src/server/org/opends/server/tools/JavaPropertiesTool.java
+++ b/opends/src/server/org/opends/server/tools/JavaPropertiesTool.java
@@ -23,7 +23,7 @@
  *
  *
  *      Copyright 2008-2009 Sun Microsystems, Inc.
- *      Portions Copyright 2011-2012 ForgeRock AS
+ *      Portions Copyright 2011-2013 ForgeRock AS
  */
 
 package org.opends.server.tools;
@@ -107,7 +107,7 @@
     {
       return returnCode;
     }
-  };
+  }
 
   final private static String DEFAULT_JAVA_HOME_PROP_NAME = "default.java-home";
   final private static String DEFAULT_JAVA_ARGS_PROP_NAME = "default.java-args";
@@ -246,7 +246,7 @@
     }
 
     Properties properties = new Properties();
-    BufferedReader reader = null;
+    BufferedReader reader;
     String propertiesFile = argParser.propertiesFileArg.getValue();
     try
     {
@@ -269,7 +269,7 @@
 
     String destinationFile = argParser.destinationFileArg.getValue();
 
-    BufferedWriter writer = null;
+    BufferedWriter writer;
     try
     {
       File f = new File(destinationFile);
@@ -565,7 +565,7 @@
           buf.append(
           s+"then"+EOL+
           s+"  TEMP=\""+value+"/bin/java\""+EOL+
-          s+"  if test -f ${TEMP}"+EOL+
+          s+"  if test -f \"${TEMP}\""+EOL+
           s+"  then"+EOL+
           s+"    OPENDJ_JAVA_BIN=\""+value+"/bin/java\""+EOL+
           s+"    export OPENDJ_JAVA_BIN"+EOL+
@@ -599,9 +599,9 @@
           buf.append(
               "  then"+EOL+
               "    TEMP=\""+defaultJavaHome+"/bin/java\""+EOL+
-              "    if test -f ${TEMP}"+EOL+
+              "    if test -f \"${TEMP}\""+EOL+
               "    then"+EOL+
-              "      OPENDJ_JAVA_BIN=${TEMP}"+EOL+
+              "      OPENDJ_JAVA_BIN=\"${TEMP}\""+EOL+
               "      export OPENDJ_JAVA_BIN"+EOL+
               "    fi"+EOL);
         }
@@ -638,19 +638,19 @@
         // No properties added: this is required not to break the script
         buf.append(
             "  then"+EOL+
-            "  OPENDJ_JAVA_BIN=${OPENDJ_JAVA_BIN}"+EOL);
+            "  OPENDJ_JAVA_BIN=\"${OPENDJ_JAVA_BIN}\""+EOL);
       }
       buf.append(
           "      else"+EOL+
-          "        OPENDJ_JAVA_BIN=${OPENDJ_JAVA_HOME}/bin/java"+EOL+
+          "        OPENDJ_JAVA_BIN=\"${OPENDJ_JAVA_HOME}/bin/java\""+EOL+
           "        export OPENDJ_JAVA_BIN"+EOL+
           "      fi"+EOL+
           "    else"+EOL+
-          "      OPENDJ_JAVA_BIN=${OPENDS_JAVA_BIN}"+EOL+
+          "      OPENDJ_JAVA_BIN=\"${OPENDS_JAVA_BIN}\""+EOL+
           "      export OPENDJ_JAVA_BIN"+EOL+
           "    fi"+EOL+
           "  else"+EOL+
-          "    OPENDJ_JAVA_BIN=${OPENDS_JAVA_HOME}/bin/java"+EOL+
+          "    OPENDJ_JAVA_BIN=\"${OPENDS_JAVA_HOME}/bin/java\""+EOL+
           "    export OPENDJ_JAVA_BIN"+EOL+
           "  fi"+EOL+
 

--
Gitblit v1.10.0