commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Benedikt Ritter <brit...@apache.org>
Subject Re: [EXEC] generics for EnvironmentUtils
Date Sat, 11 Jan 2014 12:15:47 GMT
Hello Sebb,


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

> I reverted the contentious generics change.
>
> However, I'm not sure there really is a problem here.
>
> Adding the "wrong" generics can only affect existing users that also
> use generics, i.e. they must be using Java 1.5+


> Now if a Java 5 client calls a non-generic library, they are going to
> have to either suppress the warning, or decide what types to use.
> Unless the Javadoc is clear on what is expected, then they would be
> foolish to pick on any particular types.
>
> Also the main issue - does it affect binary compatibility?
> If not, then does it matter if the source needs changing?


> Any example of the sort of code that might be affected by adding
> generics to Exec?
>

Looking at this again, this would probably only have been a problem if the
following line:

result[i] = entry.getKey().toString() + "=" + entry.getValue().toString();

would have changed to:

result[i] = entry.getKey() + "=" + entry.getValue();

which would make sense now that we're dealing with a Map<String, String>.
But then a caller that passed Map<String, Integer> would have gotten:
java.lang.ClassCastException: java.lang.Integer cannot be cast to
java.lang.String

So long story cut short: I guess this will work :-) sorry

Benedikt


>
> ---------- Forwarded message ----------
> From:  <sebb@apache.org>
> Date: 11 January 2014 11:32
> Subject: svn commit: r1557347 -
>
> /commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/environment/EnvironmentUtils.java
> To: commits@commons.apache.org
>
>
> Author: sebb
> Date: Sat Jan 11 11:32:58 2014
> New Revision: 1557347
>
> URL: http://svn.apache.org/r1557347
> Log:
> Temporarily revert generics until discussion completed
>
> Modified:
>
> commons/proper/exec/trunk/src/main/java/org/apache/commons/exec/environment/EnvironmentUtils.java
>
> 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=1557347&r1=1557346&r2=1557347&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 11:32:58 2014
> @@ -91,7 +91,7 @@ public class EnvironmentUtils
>       * @param environment the current environment
>       * @param keyAndValue the key/value pair
>       */
> -    public static void addVariableToEnvironment(final Map<String,
> String> environment, final String keyAndValue) {
> +    public static void addVariableToEnvironment(final Map
> environment, final String keyAndValue) {
>          final String[] parsedVariable =
> parseEnvironmentVariable(keyAndValue);
>          environment.put(parsedVariable[0], parsedVariable[1]);
>      }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@commons.apache.org
> For additional commands, e-mail: dev-help@commons.apache.org
>
>


-- 
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