commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benedikt Ritter <brit...@apache.org>
Subject Re: svn commit: r1557338 - in /commons/proper/exec/trunk/src: main/java/org/apache/commons/exec/ main/java/org/apache/commons/exec/environment/ main/java/org/apache/commons/exec/launcher/ main/java/org/apache/commons/exec/util/ test/java/org/apache/commons...
Date Sat, 11 Jan 2014 11:12:31 GMT
Hi Sebb,


2014/1/11 <sebb@apache.org>

> Author: sebb
> Date: Sat Jan 11 10:34:22 2014
> New Revision: 1557338
>
> URL: http://svn.apache.org/r1557338
> Log:
> Initial stab at generics
>
> Modified:
>
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java
>
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java
>
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/Executor.java
>
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java
>
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/Watchdog.java
>
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/environment/DefaultProcessingEnvironment.java
>
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/environment/EnvironmentUtils.java
>
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/environment/OpenVmsProcessingEnvironment.java
>
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/CommandLauncher.java
>
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/CommandLauncherImpl.java
>
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/CommandLauncherProxy.java
>
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/Java13CommandLauncher.java
>
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/OS2CommandLauncher.java
>
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/VmsCommandLauncher.java
>
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/WinNTCommandLauncher.java
>
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/util/StringUtils.java
>
> commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
>
> commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/environment/EnvironmentUtilTest.java
>
> commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/util/MapUtilTest.java
>
> commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/util/StringUtilTest.java
>
> Modified:
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java?rev=1557338&r1=1557337&r2=1557338&view=diff
>
> ==============================================================================
> ---
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java
> (original)
> +++
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/CommandLine.java
> Sat Jan 11 10:34:22 2014
> @@ -48,7 +48,7 @@ public class CommandLine {
>      /**
>       * A map of name value pairs used to expand command line arguments
>       */
> -    private Map substitutionMap;
> +    private Map substitutionMap; // N.B. This can contain values other
> than Strings
>
>      /**
>       * Was a file being used to set the executable?
>
> Modified:
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java?rev=1557338&r1=1557337&r2=1557338&view=diff
>
> ==============================================================================
> ---
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java
> (original)
> +++
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/DefaultExecutor.java
> Sat Jan 11 10:34:22 2014
> @@ -150,13 +150,13 @@ public class DefaultExecutor implements
>       */
>      public int execute(final CommandLine command) throws ExecuteException,
>              IOException {
> -        return execute(command, (Map) null);
> +        return execute(command, (Map<String, String>) null);
>      }
>
>      /**
>       * @see org.apache.commons.exec.Executor#execute(CommandLine,
> java.util.Map)
>       */
> -    public int execute(final CommandLine command, final Map environment)
> +    public int execute(final CommandLine command, final Map<String,
> String> environment)
>              throws ExecuteException, IOException {
>
>          if (workingDirectory != null && !workingDirectory.exists()) {
> @@ -180,7 +180,7 @@ public class DefaultExecutor implements
>       * @see org.apache.commons.exec.Executor#execute(CommandLine,
>       *      java.util.Map, org.apache.commons.exec.ExecuteResultHandler)
>       */
> -    public void execute(final CommandLine command, final Map environment,
> +    public void execute(final CommandLine command, final Map<String,
> String> environment,
>              final ExecuteResultHandler handler) throws ExecuteException,
> IOException {
>
>          if (workingDirectory != null && !workingDirectory.exists()) {
> @@ -266,7 +266,7 @@ public class DefaultExecutor implements
>       * @throws IOException
>       *             forwarded from the particular launcher used
>       */
> -    protected Process launch(final CommandLine command, final Map env,
> +    protected Process launch(final CommandLine command, final Map<String,
> String> env,
>              final File dir) throws IOException {
>
>          if (this.launcher == null) {
> @@ -328,7 +328,7 @@ public class DefaultExecutor implements
>       * @return the exit code of the process
>       * @throws IOException executing the process failed
>       */
> -    private int executeInternal(final CommandLine command, final Map
> environment,
> +    private int executeInternal(final CommandLine command, final
> Map<String, String> environment,
>              final File dir, final ExecuteStreamHandler streams) throws
> IOException {
>
>          setExceptionCaught(null);
>
> Modified:
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/Executor.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/Executor.java?rev=1557338&r1=1557337&r2=1557338&view=diff
>
> ==============================================================================
> ---
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/Executor.java
> (original)
> +++
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/Executor.java
> Sat Jan 11 10:34:22 2014
> @@ -179,7 +179,7 @@ public interface Executor {
>       *          subprocess returned a exit value indicating a failure
>       *          {@link Executor#setExitValue(int)}.
>       */
> -    int execute(CommandLine command, Map environment)
> +    int execute(CommandLine command, Map<String, String> environment)
>          throws ExecuteException, IOException;
>
>      /**
> @@ -205,6 +205,6 @@ public interface Executor {
>       * @param handler capture process termination and exit code
>       * @throws ExecuteException execution of subprocess failed
>       */
> -    void execute(CommandLine command, Map environment,
> ExecuteResultHandler handler)
> +    void execute(CommandLine command, Map<String, String> environment,
> ExecuteResultHandler handler)
>          throws ExecuteException, IOException;
>  }
>
> Modified:
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java?rev=1557338&r1=1557337&r2=1557338&view=diff
>
> ==============================================================================
> ---
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java
> (original)
> +++
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/ShutdownHookProcessDestroyer.java
> Sat Jan 11 10:34:22 2014
> @@ -29,7 +29,7 @@ import java.util.Vector;
>  public class ShutdownHookProcessDestroyer implements ProcessDestroyer,
> Runnable {
>
>      /** the list of currently running processes */
> -    private final Vector processes = new Vector();
> +    private final Vector<Process> processes = new Vector<Process>();
>
>      /** The thread registered at the JVM to execute the shutdown handler
> */
>      private ProcessDestroyerImpl destroyProcessThread = null;
> @@ -182,9 +182,9 @@ public class ShutdownHookProcessDestroye
>    public void run() {
>        synchronized (processes) {
>            running = true;
> -          final Enumeration e = processes.elements();
> +          final Enumeration<Process> e = processes.elements();
>            while (e.hasMoreElements()) {
> -              final Process process = (Process) e.nextElement();
> +              final Process process = e.nextElement();
>                try {
>                    process.destroy();
>                }
>
> Modified:
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/Watchdog.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/Watchdog.java?rev=1557338&r1=1557337&r2=1557338&view=diff
>
> ==============================================================================
> ---
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/Watchdog.java
> (original)
> +++
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/Watchdog.java
> Sat Jan 11 10:34:22 2014
> @@ -30,7 +30,7 @@ import java.util.Vector;
>   */
>  public class Watchdog implements Runnable {
>
> -    private final Vector observers = new Vector(1);
> +    private final Vector<TimeoutObserver> observers = new
> Vector<TimeoutObserver>(1);
>
>      private final long timeout;
>
> @@ -52,9 +52,9 @@ public class Watchdog implements Runnabl
>      }
>
>      protected final void fireTimeoutOccured() {
> -        final Enumeration e = observers.elements();
> +        final Enumeration<TimeoutObserver> e = observers.elements();
>          while (e.hasMoreElements()) {
> -            ((TimeoutObserver) e.nextElement()).timeoutOccured(this);
> +            e.nextElement().timeoutOccured(this);
>          }
>      }
>
>
> Modified:
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/environment/DefaultProcessingEnvironment.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/environment/DefaultProcessingEnvironment.java?rev=1557338&r1=1557337&r2=1557338&view=diff
>
> ==============================================================================
> ---
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/environment/DefaultProcessingEnvironment.java
> (original)
> +++
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/environment/DefaultProcessingEnvironment.java
> Sat Jan 11 10:34:22 2014
> @@ -50,7 +50,7 @@ public class DefaultProcessingEnvironmen
>      private static final String LINE_SEPARATOR =
> System.getProperty("line.separator");
>
>      /** the environment variables of the process */
> -    protected Map procEnvironment;
> +    protected Map<String, String> procEnvironment;
>
>      /**
>       * Find the list of environment variables for this process.
> @@ -58,7 +58,7 @@ public class DefaultProcessingEnvironmen
>       * @return a map containing the environment variables
>       * @throws IOException obtaining the environment variables failed
>       */
> -    public synchronized Map getProcEnvironment() throws IOException {
> +    public synchronized Map<String, String> getProcEnvironment() throws
> IOException {
>
>          if (procEnvironment == null) {
>              procEnvironment = this.createProcEnvironment();
> @@ -67,7 +67,7 @@ public class DefaultProcessingEnvironmen
>          // create a copy of the map just in case that
>          // anyone is going to modifiy it, e.g. removing
>          // or setting an evironment variable
> -        final Map copy = createEnvironmentMap();
> +        final Map<String, String> copy = createEnvironmentMap();
>          copy.putAll(procEnvironment);
>          return copy;
>      }
> @@ -78,11 +78,11 @@ public class DefaultProcessingEnvironmen
>       * @return a amp containing the environment variables
>       * @throws IOException the operation failed
>       */
> -    protected Map createProcEnvironment() throws IOException {
> +    protected Map<String, String> createProcEnvironment() throws
> IOException {
>          if (procEnvironment == null) {
>              try {
>                  final Method getenvs = System.class.getMethod("getenv",
> (java.lang.Class[]) null);
> -                final Map env = (Map) getenvs.invoke(null,
> (java.lang.Object[]) null);
> +                final Map<String, String> env = (Map<String, String>)
> getenvs.invoke(null, (java.lang.Object[]) null);
>                  procEnvironment = createEnvironmentMap();
>                  procEnvironment.putAll(env);
>              } catch (final NoSuchMethodException e) {
> @@ -226,17 +226,15 @@ public class DefaultProcessingEnvironmen
>       * @return The map for storage of environment variables, never
>       *         <code>null</code>.
>       */
> -    private Map createEnvironmentMap() {
> +    private Map<String, String> createEnvironmentMap() {
>          if (OS.isFamilyWindows()) {
> -            return new TreeMap(new Comparator() {
> -                public int compare(final Object arg0, final Object arg1) {
> -                    final String key0 = (String) arg0;
> -                    final String key1 = (String) arg1;
> +            return new TreeMap<String, String>(new Comparator<String>()
{
> +                public int compare(final String key0, final String key1) {
>                      return key0.compareToIgnoreCase(key1);
>                  }
>              });
>          }
> -               return new HashMap();
> +               return new HashMap<String, String>();
>      }
>
>  }
>
> Modified:
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/environment/EnvironmentUtils.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/environment/EnvironmentUtils.java?rev=1557338&r1=1557337&r2=1557338&view=diff
>
> ==============================================================================
> ---
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/environment/EnvironmentUtils.java
> (original)
> +++
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/environment/EnvironmentUtils.java
> Sat Jan 11 10:34:22 2014
> @@ -56,14 +56,14 @@ public class EnvironmentUtils
>       * @return array of key=value assignment strings or <code>null</code>
> if and only if
>       *     the input map was <code>null</code>
>       */
> -    public static String[] toStrings(final Map environment) {
> +    public static String[] toStrings(final Map<String, String>
> environment) {
>

This may break clients, since the code worked with an arbitrary typed map
before but now requires a Map<String, String>.  I think we should go with
Map<K, V> here.


>          if (environment == null) {
>              return null;
>          }
>          final String[] result = new String[environment.size()];
>          int i = 0;
> -        for (final Iterator iter = environment.entrySet().iterator();
> iter.hasNext();) {
> -            final Map.Entry entry = (Map.Entry) iter.next();
> +        for (final Iterator<Map.Entry<String, String>> iter =
> environment.entrySet().iterator(); iter.hasNext();) {
> +            final Map.Entry<String, String> entry = iter.next();
>
>              result[i] = entry.getKey().toString() + "=" +
> entry.getValue().toString();
>              i++;
> @@ -80,7 +80,7 @@ public class EnvironmentUtils
>       * @return a map containing the environment variables, may be empty
> but never <code>null</code>
>       * @throws IOException the operation failed
>       */
> -    public static Map getProcEnvironment() throws IOException {
> +    public static Map<String, String> getProcEnvironment() throws
> IOException {
>          return PROCESSING_ENVIRONMENT_IMPLEMENTATION.getProcEnvironment();
>      }
>
> @@ -91,7 +91,7 @@ public class EnvironmentUtils
>       * @param environment the current environment
>       * @param keyAndValue the key/value pair
>       */
> -    public static void addVariableToEnvironment(final Map environment,
> final String keyAndValue) {
> +    public static void addVariableToEnvironment(final Map<String, String>
> environment, final String keyAndValue) {
>          final String[] parsedVariable =
> parseEnvironmentVariable(keyAndValue);
>          environment.put(parsedVariable[0], parsedVariable[1]);
>      }
>
> Modified:
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/environment/OpenVmsProcessingEnvironment.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/environment/OpenVmsProcessingEnvironment.java?rev=1557338&r1=1557337&r2=1557338&view=diff
>
> ==============================================================================
> ---
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/environment/OpenVmsProcessingEnvironment.java
> (original)
> +++
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/environment/OpenVmsProcessingEnvironment.java
> Sat Jan 11 10:34:22 2014
> @@ -39,10 +39,10 @@ public class OpenVmsProcessingEnvironmen
>       * @throws IOException the operation failed
>       */
>      @Override
> -    protected Map createProcEnvironment() throws IOException {
> +    protected Map<String, String> createProcEnvironment() throws
> IOException {
>          if (procEnvironment == null) {
>              final BufferedReader in = runProcEnvCommand();
> -            procEnvironment = addVMSenvironmentVariables(new HashMap(),
> in);
> +            procEnvironment = addVMSenvironmentVariables(new
> HashMap<String, String>(), in);
>          }
>
>          return procEnvironment;
> @@ -72,7 +72,7 @@ public class OpenVmsProcessingEnvironmen
>       * @return the updated environment
>       * @throws IOException operation failed
>       */
> -    private Map addVMSenvironmentVariables(final Map environment,
> +    private Map<String, String> addVMSenvironmentVariables(final
> Map<String, String> environment,
>              final BufferedReader in) throws IOException {
>          String line;
>          while ((line = in.readLine()) != null) {
>
> Modified:
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/CommandLauncher.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/CommandLauncher.java?rev=1557338&r1=1557337&r2=1557338&view=diff
>
> ==============================================================================
> ---
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/CommandLauncher.java
> (original)
> +++
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/CommandLauncher.java
> Sat Jan 11 10:34:22 2014
> @@ -45,7 +45,7 @@ public interface CommandLauncher {
>       * @throws IOException
>       *             if attempting to run a command in a specific directory
>       */
> -    Process exec(final CommandLine cmd, final Map env)
> +    Process exec(final CommandLine cmd, final Map<String, String> env)
>              throws IOException;
>
>      /**
> @@ -65,7 +65,7 @@ public interface CommandLauncher {
>       * @throws IOException
>       *             if trying to change directory
>       */
> -    Process exec(final CommandLine cmd, final Map env,
> +    Process exec(final CommandLine cmd, final Map<String, String> env,
>              final File workingDir) throws IOException;
>
>
>
> Modified:
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/CommandLauncherImpl.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/CommandLauncherImpl.java?rev=1557338&r1=1557337&r2=1557338&view=diff
>
> ==============================================================================
> ---
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/CommandLauncherImpl.java
> (original)
> +++
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/CommandLauncherImpl.java
> Sat Jan 11 10:34:22 2014
> @@ -34,13 +34,13 @@ import org.apache.commons.exec.environme
>   */
>  public abstract class CommandLauncherImpl implements CommandLauncher {
>
> -    public Process exec(final CommandLine cmd, final Map env)
> +    public Process exec(final CommandLine cmd, final Map<String, String>
> env)
>              throws IOException {
>          final String[] envVar = EnvironmentUtils.toStrings(env);
>          return Runtime.getRuntime().exec(cmd.toStrings(), envVar);
>      }
>
> -    public abstract Process exec(final CommandLine cmd, final Map env,
> +    public abstract Process exec(final CommandLine cmd, final Map<String,
> String> env,
>              final File workingDir) throws IOException;
>
>      /** @see
> org.apache.commons.exec.launcher.CommandLauncher#isFailure(int) */
>
> Modified:
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/CommandLauncherProxy.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/CommandLauncherProxy.java?rev=1557338&r1=1557337&r2=1557338&view=diff
>
> ==============================================================================
> ---
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/CommandLauncherProxy.java
> (original)
> +++
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/CommandLauncherProxy.java
> Sat Jan 11 10:34:22 2014
> @@ -49,7 +49,7 @@ public abstract class CommandLauncherPro
>       *             forwarded from the exec method of the command launcher
>       */
>      @Override
> -    public Process exec(final CommandLine cmd, final Map env)
> +    public Process exec(final CommandLine cmd, final Map<String, String>
> env)
>              throws IOException {
>          return myLauncher.exec(cmd, env);
>      }
>
> Modified:
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/Java13CommandLauncher.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/Java13CommandLauncher.java?rev=1557338&r1=1557337&r2=1557338&view=diff
>
> ==============================================================================
> ---
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/Java13CommandLauncher.java
> (original)
> +++
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/Java13CommandLauncher.java
> Sat Jan 11 10:34:22 2014
> @@ -53,7 +53,7 @@ public class Java13CommandLauncher exten
>       *             probably forwarded from Runtime#exec
>       */
>      @Override
> -    public Process exec(final CommandLine cmd, final Map env,
> +    public Process exec(final CommandLine cmd, final Map<String, String>
> env,
>              final File workingDir) throws IOException {
>
>          final String[] envVars = EnvironmentUtils.toStrings(env);
>
> Modified:
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/OS2CommandLauncher.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/OS2CommandLauncher.java?rev=1557338&r1=1557337&r2=1557338&view=diff
>
> ==============================================================================
> ---
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/OS2CommandLauncher.java
> (original)
> +++
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/OS2CommandLauncher.java
> Sat Jan 11 10:34:22 2014
> @@ -56,7 +56,7 @@ public class OS2CommandLauncher extends
>       *             forwarded from the exec method of the command launcher
>       */
>      @Override
> -    public Process exec(final CommandLine cmd, final Map env,
> +    public Process exec(final CommandLine cmd, final Map<String, String>
> env,
>              final File workingDir) throws IOException {
>          if (workingDir == null) {
>              return exec(cmd, env);
>
> Modified:
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/VmsCommandLauncher.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/VmsCommandLauncher.java?rev=1557338&r1=1557337&r2=1557338&view=diff
>
> ==============================================================================
> ---
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/VmsCommandLauncher.java
> (original)
> +++
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/VmsCommandLauncher.java
> Sat Jan 11 10:34:22 2014
> @@ -43,7 +43,7 @@ public class VmsCommandLauncher extends
>       * Launches the given command in a new process.
>       */
>      @Override
> -    public Process exec(final CommandLine cmd, final Map env)
> +    public Process exec(final CommandLine cmd, final Map<String, String>
> env)
>              throws IOException {
>          final CommandLine vmsCmd = new CommandLine(
>                  createCommandFile(cmd, env).getPath()
> @@ -59,7 +59,7 @@ public class VmsCommandLauncher extends
>       * JAVA$FORK_SUPPORT_CHDIR needs to be set to TRUE.
>       */
>      @Override
> -    public Process exec(final CommandLine cmd, final Map env,
> +    public Process exec(final CommandLine cmd, final Map<String, String>
> env,
>              final File workingDir) throws IOException {
>          final CommandLine vmsCmd = new CommandLine(
>                  createCommandFile(cmd, env).getPath()
> @@ -79,7 +79,7 @@ public class VmsCommandLauncher extends
>       * Writes the command into a temporary DCL script and returns the
>       * corresponding File object. The script will be deleted on exit.
>       */
> -    private File createCommandFile(final CommandLine cmd, final Map env)
> +    private File createCommandFile(final CommandLine cmd, final
> Map<String, String> env)
>              throws IOException {
>          final File script = File.createTempFile("EXEC", ".TMP");
>          script.deleteOnExit();
> @@ -89,15 +89,15 @@ public class VmsCommandLauncher extends
>
>              // add the environment as global symbols for the DCL script
>              if (env != null) {
> -                final Set entries = env.entrySet();
> +                final Set<Entry<String, String>> entries = env.entrySet();
>
> -                for (final Iterator iter = entries.iterator();
> iter.hasNext();) {
> -                    final Entry entry = (Entry) iter.next();
> +                for (final Iterator<Entry<String, String>> iter =
> entries.iterator(); iter.hasNext();) {
> +                    final Entry<String, String> entry = iter.next();
>                      out.print("$ ");
>                      out.print(entry.getKey());
>                      out.print(" == "); // define as global symbol
>                      out.println('\"');
> -                    String value = (String) entry.getValue();
> +                    String value = entry.getValue();
>                      // Any embedded " values need to be doubled
>                      if (value.indexOf('\"') > 0) {
>                          final StringBuffer sb = new StringBuffer();
>
> Modified:
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/WinNTCommandLauncher.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/WinNTCommandLauncher.java?rev=1557338&r1=1557337&r2=1557338&view=diff
>
> ==============================================================================
> ---
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/WinNTCommandLauncher.java
> (original)
> +++
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/launcher/WinNTCommandLauncher.java
> Sat Jan 11 10:34:22 2014
> @@ -49,7 +49,7 @@ public class WinNTCommandLauncher extend
>       *             forwarded from the exec method of the command launcher
>       */
>      @Override
> -    public Process exec(final CommandLine cmd, final Map env,
> +    public Process exec(final CommandLine cmd, final Map<String, String>
> env,
>              final File workingDir) throws IOException {
>          if (workingDir == null) {
>              return exec(cmd, env);
>
> Modified:
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/util/StringUtils.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/util/StringUtils.java?rev=1557338&r1=1557337&r2=1557338&view=diff
>
> ==============================================================================
> ---
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/util/StringUtils.java
> (original)
> +++
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/util/StringUtils.java
> Sat Jan 11 10:34:22 2014
> @@ -160,11 +160,11 @@ public class StringUtils {
>       */
>      public static String[] split(final String input, final String
> splitChar) {
>          final StringTokenizer tokens = new StringTokenizer(input,
> splitChar);
> -        final List strList = new ArrayList();
> +        final List<String> strList = new ArrayList<String>();
>          while (tokens.hasMoreTokens()) {
>              strList.add(tokens.nextToken());
>          }
> -        return (String[]) strList.toArray(new String[strList.size()]);
> +        return strList.toArray(new String[strList.size()]);
>      }
>
>      /**
>
> Modified:
> commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java?rev=1557338&r1=1557337&r2=1557338&view=diff
>
> ==============================================================================
> ---
> commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
> (original)
> +++
> commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/DefaultExecutorTest.java
> Sat Jan 11 10:34:22 2014
> @@ -172,7 +172,7 @@ public class DefaultExecutorTest {
>       */
>      @Test
>      public void testExecuteWithSingleEnvironmentVariable() throws
> Exception {
> -        final Map env = new HashMap();
> +        final Map<String, String> env = new HashMap<String, String>();
>          env.put("TEST_ENV_VAR", "XYZ");
>
>          final CommandLine cl = new CommandLine(testScript);
> @@ -662,7 +662,7 @@ public class DefaultExecutorTest {
>       */
>      @Test
>      public void testAddEnvironmentVariables() throws Exception {
> -        final Map myEnvVars = new HashMap();
> +        final Map<String, String> myEnvVars = new HashMap<String,
> String>();
>          myEnvVars.putAll(EnvironmentUtils.getProcEnvironment());
>          myEnvVars.put("NEW_VAR","NEW_VAL");
>          exec.execute(new CommandLine(environmentSript), myEnvVars);
>
> Modified:
> commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/environment/EnvironmentUtilTest.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/environment/EnvironmentUtilTest.java?rev=1557338&r1=1557337&r2=1557338&view=diff
>
> ==============================================================================
> ---
> commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/environment/EnvironmentUtilTest.java
> (original)
> +++
> commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/environment/EnvironmentUtilTest.java
> Sat Jan 11 10:34:22 2014
> @@ -29,6 +29,7 @@ import java.util.HashMap;
>  import java.util.Iterator;
>  import java.util.Locale;
>  import java.util.Map;
> +import java.util.Map.Entry;
>
>  import org.apache.commons.exec.OS;
>  import org.junit.Test;
> @@ -47,7 +48,7 @@ public class EnvironmentUtilTest {
>          // check for a non-existing environment when passing null
>          assertNull(EnvironmentUtils.toStrings(null));
>          // check for an environment when filling in two variables
> -        final Map env = new HashMap();
> +        final Map<String, String> env = new HashMap<String, String>();
>          assertArrayEquals(new String[0], EnvironmentUtils.toStrings(env));
>          env.put("foo2", "bar2");
>          env.put("foo", "bar");
> @@ -65,7 +66,7 @@ public class EnvironmentUtilTest {
>       */
>      @Test
>      public void testGetProcEnvironment() throws IOException {
> -        final Map procEnvironment = EnvironmentUtils.getProcEnvironment();
> +        final Map<String, String> procEnvironment =
> EnvironmentUtils.getProcEnvironment();
>          // we assume that there is at least one environment variable
>          // for this process, i.e. $JAVA_HOME
>          assertTrue("Expecting non-zero environment size",
> procEnvironment.size() > 0);
> @@ -92,11 +93,11 @@ public class EnvironmentUtilTest {
>          }
>
>          // ensure that we have the same value for upper and lowercase keys
> -        final Map procEnvironment = EnvironmentUtils.getProcEnvironment();
> -        for (final Iterator it = procEnvironment.entrySet().iterator();
> it.hasNext();) {
> -            final Map.Entry entry = (Map.Entry) it.next();
> -            final String key = (String) entry.getKey();
> -            final String value = (String) entry.getValue();
> +        final Map<String, String> procEnvironment =
> EnvironmentUtils.getProcEnvironment();
> +        for (final Iterator<Entry<String, String>> it =
> procEnvironment.entrySet().iterator(); it.hasNext();) {
> +            final Entry<String, String> entry = it.next();
> +            final String key = entry.getKey();
> +            final String value = entry.getValue();
>              assertEquals(value,
> procEnvironment.get(key.toLowerCase(Locale.ENGLISH)));
>              assertEquals(value,
> procEnvironment.get(key.toUpperCase(Locale.ENGLISH)));
>          }
> @@ -118,7 +119,7 @@ public class EnvironmentUtilTest {
>       */
>      @Test
>      public void testCaseInsensitiveVariableLookup() throws Exception {
> -        final Map procEnvironment = EnvironmentUtils.getProcEnvironment();
> +        final Map<String, String> procEnvironment =
> EnvironmentUtils.getProcEnvironment();
>          // Check that case is preserved for values
>          EnvironmentUtils.addVariableToEnvironment(procEnvironment,
> "foo=bAr");
>          assertEquals("bAr", procEnvironment.get("foo"));
>
> Modified:
> commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/util/MapUtilTest.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/util/MapUtilTest.java?rev=1557338&r1=1557337&r2=1557338&view=diff
>
> ==============================================================================
> ---
> commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/util/MapUtilTest.java
> (original)
> +++
> commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/util/MapUtilTest.java
> Sat Jan 11 10:34:22 2014
> @@ -37,7 +37,7 @@ public class MapUtilTest {
>      @Test
>      public void testCopyMap() throws Exception {
>
> -        final HashMap procEnvironment = new HashMap();
> +        final HashMap<String, String> procEnvironment = new
> HashMap<String, String>();
>          procEnvironment.put("JAVA_HOME", "/usr/opt/java");
>
>          final Map result = MapUtils.copy(procEnvironment);
> @@ -56,11 +56,11 @@ public class MapUtilTest {
>      @Test
>      public void testMergeMap() throws Exception {
>
> -        final Map procEnvironment = EnvironmentUtils.getProcEnvironment();
> -        final HashMap applicationEnvironment = new HashMap();
> +        final Map<String, String> procEnvironment =
> EnvironmentUtils.getProcEnvironment();
> +        final HashMap<String, String> applicationEnvironment = new
> HashMap<String, String>();
>
>          applicationEnvironment.put("appMainClass", "foo.bar.Main");
> -        final Map result = MapUtils.merge(procEnvironment,
> applicationEnvironment);
> +        final Map<String, String> result =
> MapUtils.merge(procEnvironment, applicationEnvironment);
>          assertTrue(procEnvironment.size() + applicationEnvironment.size()
> == result.size());
>          assertEquals("foo.bar.Main", result.get("appMainClass"));
>      }
> @@ -71,7 +71,7 @@ public class MapUtilTest {
>      @Test
>      public void testPrefixMap() throws Exception {
>
> -        final HashMap procEnvironment = new HashMap();
> +        final HashMap<String, String> procEnvironment = new
> HashMap<String, String>();
>          procEnvironment.put("JAVA_HOME", "/usr/opt/java");
>
>          final Map result = MapUtils.prefix(procEnvironment, "env");
>
> Modified:
> commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/util/StringUtilTest.java
> URL:
> http://svn.apache.org/viewvc/commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/util/StringUtilTest.java?rev=1557338&r1=1557337&r2=1557338&view=diff
>
> ==============================================================================
> ---
> commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/util/StringUtilTest.java
> (original)
> +++
> commons/proper/exec/trunk/src/test/java/org/apache/commons/exec/util/StringUtilTest.java
> Sat Jan 11 10:34:22 2014
> @@ -36,7 +36,7 @@ public class StringUtilTest {
>      @Test
>      public void testNoStringSubstitution() throws Exception
>      {
> -        final Map vars = new HashMap();
> +        final Map<String, String> vars = new HashMap<String, String>();
>          vars.put("foo", "FOO");
>          vars.put("bar", "BAR");
>
> @@ -50,7 +50,7 @@ public class StringUtilTest {
>      @Test
>      public void testDefaultStringSubstitution() throws Exception
>      {
> -        final Map vars = new HashMap();
> +        final Map<String, String> vars = new HashMap<String, String>();
>          vars.put("foo", "FOO");
>          vars.put("bar", "BAR");
>
> @@ -65,7 +65,7 @@ public class StringUtilTest {
>      @Test
>      public void testIncompleteSubstitution() throws Exception {
>
> -        final Map vars = new HashMap();
> +        final Map<String, String> vars = new HashMap<String, String>();
>          vars.put("foo", "FOO");
>
>          assertEquals("This is a FOO & ${bar} test",
>  StringUtils.stringSubstitution("This is a ${foo} & ${bar} test", vars,
> true).toString());
> @@ -87,7 +87,7 @@ public class StringUtilTest {
>      @Test
>      public void testErroneousTemplate() throws Exception
>      {
> -        final Map vars = new HashMap();
> +        final Map<String, String> vars = new HashMap<String, String>();
>          vars.put("foo", "FOO");
>
>          assertEquals("This is a FOO & ${}} test",
>  StringUtils.stringSubstitution("This is a ${foo} & ${}} test", vars,
> true).toString());
>
>
>


-- 
http://people.apache.org/~britter/
http://www.systemoutprintln.de/
http://twitter.com/BenediktRitter
http://github.com/britter

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message