You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stanbol.apache.org by og...@apache.org on 2011/02/11 18:38:23 UTC

svn commit: r1069903 - /incubator/stanbol/trunk/commons/testing/jarexec/src/main/java/org/apache/stanbol/commons/testing/jarexec/JarExecutor.java

Author: ogrisel
Date: Fri Feb 11 17:38:23 2011
New Revision: 1069903

URL: http://svn.apache.org/viewvc?rev=1069903&view=rev
Log:
STANBOL-79: make it possible to pass several vm options

Modified:
    incubator/stanbol/trunk/commons/testing/jarexec/src/main/java/org/apache/stanbol/commons/testing/jarexec/JarExecutor.java

Modified: incubator/stanbol/trunk/commons/testing/jarexec/src/main/java/org/apache/stanbol/commons/testing/jarexec/JarExecutor.java
URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/commons/testing/jarexec/src/main/java/org/apache/stanbol/commons/testing/jarexec/JarExecutor.java?rev=1069903&r1=1069902&r2=1069903&view=diff
==============================================================================
--- incubator/stanbol/trunk/commons/testing/jarexec/src/main/java/org/apache/stanbol/commons/testing/jarexec/JarExecutor.java (original)
+++ incubator/stanbol/trunk/commons/testing/jarexec/src/main/java/org/apache/stanbol/commons/testing/jarexec/JarExecutor.java Fri Feb 11 17:38:23 2011
@@ -27,6 +27,7 @@ import org.apache.commons.exec.ExecuteEx
 import org.apache.commons.exec.ExecuteResultHandler;
 import org.apache.commons.exec.Executor;
 import org.apache.commons.exec.ShutdownHookProcessDestroyer;
+import org.apache.commons.exec.util.StringUtils;
 
 /** Start a runnable jar by forking a JVM process,
  *  and terminate the process when this VM exits.
@@ -128,11 +129,15 @@ public class JarExecutor {
             }
         };
 
-        final String vmOptions = System.getProperty("jar.executor.vm.options"); 
+        final String vmOptions = System.getProperty("jar.executor.vm.options");
         final Executor e = new DefaultExecutor();
         final CommandLine cl = new CommandLine(javaExecutable);
-        if(vmOptions != null && vmOptions.length() > 0) {
-            cl.addArgument(vmOptions);
+        if (vmOptions != null && vmOptions.length() > 0) {
+            // TODO: this will fail if one of the vm options as a quoted value with a space in it, but this is
+            // not the case for common usage patterns
+            for (String option : StringUtils.split(vmOptions, " ")) {
+                cl.addArgument(option);
+            }
         }
         cl.addArgument("-jar");
         cl.addArgument(jarToExecute.getAbsolutePath());