harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Deakin <oliver.dea...@googlemail.com>
Subject Re: svn commit: r938116 - /harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/platform/Environment.java
Date Fri, 30 Apr 2010 10:49:14 GMT
On 30/04/2010 05:33, Nathan Beyer wrote:
> On Mon, Apr 26, 2010 at 11:31 AM,<odeakin@apache.org>  wrote:
>    
>> Author: odeakin
>> Date: Mon Apr 26 16:31:15 2010
>> New Revision: 938116
>>
>> URL: http://svn.apache.org/viewvc?rev=938116&view=rev
>> Log:
>> Make sure that we use a consistent encoding across platforms, as getBytes() and String(byte[])
use the default platform encoding if it is not specified which causes these calls to fail
on, for example, z/OS.
>>
>> Modified:
>>     harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/platform/Environment.java
>>
>> Modified: harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/platform/Environment.java
>> URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/platform/Environment.java?rev=938116&r1=938115&r2=938116&view=diff
>> ==============================================================================
>> --- harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/platform/Environment.java
(original)
>> +++ harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/org/apache/harmony/luni/platform/Environment.java
Mon Apr 26 16:31:15 2010
>> @@ -16,6 +16,7 @@
>>
>>   package org.apache.harmony.luni.platform;
>>
>> +import java.io.UnsupportedEncodingException;
>>   import java.util.Collections;
>>   import java.util.HashMap;
>>   import java.util.Map;
>> @@ -63,11 +64,16 @@ public class Environment {
>>       * @return the value of the environment variable specified
>>       */
>>      public static String getenv(String name) {
>> -        byte[] env = getEnvByName(name.getBytes());
>> -        if (null == env) {
>> -            return null;
>> -        }
>> -        return new String(env);
>> +        try {
>> +             byte[] env = getEnvByName(name.getBytes("UTF-8"));
>> +             if (null == env) {
>> +                return null;
>> +            }
>> +            return new String(env, "UTF-8");
>> +        } catch (UnsupportedEncodingException e) {
>> +            // UTF-8 should always be supported so this should not be reached
>> +            throw new RuntimeException(e);
>>      
> Any objections to using the 'throw new AssertionError(e)' idiom in
> this case instead of RuntimeException?
>    

None at all, I just didn't think of it at the time of the commit. 
Replaced RuntimeException with AssertionError at r939629.

Regards,
Oliver

>    
>> +        }
>>      }
>>
>>      public static class EnvironmentMap extends HashMap<String, String>  {
>>
>>
>>
>>      
>    

-- 
Oliver Deakin
Unless stated otherwise above:
IBM United Kingdom Limited - Registered in England and Wales with number 741598.
Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU


Mime
View raw message