harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lian...@apache.org
Subject svn commit: r489034 - 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 Wed, 20 Dec 2006 11:02:19 GMT
Author: liangyx
Date: Wed Dec 20 03:02:18 2006
New Revision: 489034

URL: http://svn.apache.org/viewvc?view=rev&rev=489034
Log:
Apply patch for HARMONY-2675 ([classlib][luni]ProcessBuilder.command returns a list that does
not support add() operation but RI does.)

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=489034&r1=489033&r2=489034
==============================================================================
--- 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
Wed Dec 20 03:02:18 2006
@@ -18,7 +18,7 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.util.Arrays;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -47,7 +47,7 @@
      * @param command The program and arguments.
      */
     public ProcessBuilder(String... command) {
-        this(Arrays.asList(command));
+        this(toList(command));
     }
 
     /**
@@ -90,7 +90,7 @@
      * @return A reference to this instance.
      */
     public ProcessBuilder command(String... command) {
-        return command(Arrays.asList(command));
+        return command(toList(command));
     }
 
     /**
@@ -214,6 +214,14 @@
         Process process = Runtime.getRuntime().exec(cmdArray, envArray, directory);
         // TODO implement support for redirectErrorStream
         return process;
+    }
+    
+    private static List<String> toList(String[] strings) {
+        ArrayList<String> arrayList = new ArrayList<String>(strings.length);
+        for (String string : strings) {
+            arrayList.add(string);
+        }
+        return arrayList;
     }
 }
 

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=489034&r1=489033&r2=489034
==============================================================================
--- 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
Wed Dec 20 03:02:18 2006
@@ -18,6 +18,7 @@
 
 import java.io.File;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 
@@ -41,6 +42,15 @@
         ProcessBuilder pb = new ProcessBuilder("command");
         assertEquals(1, pb.command().size());
         assertEquals("command", pb.command().get(0));
+
+        // Regression for HARMONY-2675
+        pb = new ProcessBuilder("AAA");
+        pb.command("BBB","CCC");
+        List<String> list = pb.command();
+        list.add("DDD");
+        String[] command = new String[3];
+        list.toArray(command);
+        assertTrue(Arrays.equals(new String[]{"BBB","CCC","DDD"}, command));
     }
 
     public void testCommandStringArray() {



Mime
View raw message