[Pydev-cvs] org.python.pydev/src/org/python/pydev/runners SimpleRunner.java, 1.26, 1.27
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2008-07-31 23:48:09
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/runners In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14076/src/org/python/pydev/runners Modified Files: SimpleRunner.java Log Message: - Fixed problems when calling Runtime.exec([]) with empty/null args - Fixed synch problem getting code analysis severities Index: SimpleRunner.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/runners/SimpleRunner.java,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** SimpleRunner.java 14 Jun 2008 22:14:55 -0000 1.26 --- SimpleRunner.java 31 Jul 2008 23:48:17 -0000 1.27 *************** *** 38,45 **** */ public static Process createProcess(String[] cmdarray, File workingDir) throws IOException { ! return Runtime.getRuntime().exec(cmdarray, null, workingDir); } /** * THIS CODE IS COPIED FROM org.eclipse.debug.internal.core.LaunchManager * --- 38,68 ---- */ public static Process createProcess(String[] cmdarray, File workingDir) throws IOException { ! return Runtime.getRuntime().exec(getWithoutEmptyParams(cmdarray), null, workingDir); ! } ! ! /** ! * Passes the commands directly to Runtime.exec (with a null envp) ! */ ! public static Process createProcess(String[] cmdarray, String[] envp, File workingDir) throws IOException { ! return Runtime.getRuntime().exec(getWithoutEmptyParams(cmdarray), getWithoutEmptyParams(envp), workingDir); } /** + * @return a new array without any null/empty elements originally contained in the array. + */ + private static String[] getWithoutEmptyParams(String[] cmdarray) { + if(cmdarray == null){ + return null; + } + ArrayList<String> list = new ArrayList<String>(); + for (String string : cmdarray) { + if(string != null && string.length() > 0){ + list.add(string); + } + } + return list.toArray(new String[list.size()]); + } + + /** * THIS CODE IS COPIED FROM org.eclipse.debug.internal.core.LaunchManager * *************** *** 306,310 **** } } ! process = Runtime.getRuntime().exec(cmdarray, envp, workingDir); } catch (Exception e) { throw new RuntimeException(e); --- 329,333 ---- } } ! process = createProcess(cmdarray, envp, workingDir); } catch (Exception e) { throw new RuntimeException(e); |