harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lian...@apache.org
Subject svn commit: r478775 - in /harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/lang/ProcessBuilder.java test/java/org/apache/harmony/luni/tests/java/lang/ProcessBuilderTest.java
Date Fri, 24 Nov 2006 05:59:43 GMT
Author: liangyx
Date: Thu Nov 23 21:59:37 2006
New Revision: 478775

URL: http://svn.apache.org/viewvc?view=rev&rev=478775
Log:
apply patch for HARMONY-2257 ([classlib][luni]should throw ClassCastException when get value
with an non String parameter in env Map.)

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ProcessBuilder.java
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ProcessBuilderTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ProcessBuilder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ProcessBuilder.java?view=diff&rev=478775&r1=478774&r2=478775
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ProcessBuilder.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ProcessBuilder.java
Thu Nov 23 21:59:37 2006
@@ -217,9 +217,7 @@
         return process;
     }
     
-    private class ProcessHashMap<K, V> extends HashMap<K, V> {
-
-        private static final long serialVersionUID = 1L;
+    private static class ProcessHashMap<K, V> extends HashMap<K, V> {
 
         public ProcessHashMap(Map<K, V> env) {
             super(env);
@@ -235,6 +233,9 @@
         public V get(Object key) {
             if(key == null){
                 throw new NullPointerException();
+            }
+            if(!(key instanceof String)){
+                throw new ClassCastException(key.getClass().getName());
             }
             return super.get(key);
         }

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ProcessBuilderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ProcessBuilderTest.java?view=diff&rev=478775&r1=478774&r2=478775
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ProcessBuilderTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/ProcessBuilderTest.java
Thu Nov 23 21:59:37 2006
@@ -108,6 +108,12 @@
         } catch (NullPointerException e) {
             // expected;
         }
+        try {
+            env.get(new Object());
+            fail("should throw ClassCastException.");
+        } catch (ClassCastException e) {
+            // expected;
+        }
     }
 
     public void testRedirectErrorStream() {



Mime
View raw message