harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gshiman...@apache.org
Subject svn commit: r501584 - in /harmony/enhanced: classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/process/ classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/ drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/
Date Tue, 30 Jan 2007 21:43:52 GMT
Author: gshimansky
Date: Tue Jan 30 13:43:51 2007
New Revision: 501584

URL: http://svn.apache.org/viewvc?view=rev&rev=501584
Log:
Applied HARMONY-2735 [luni][kernel] in/out/err streams of the j.l.Process impl should be buffered

VM tests passed on Ubuntu6 x86, Windows XP x86 and SuSE9 x86_64
Classlib LUNI tests passed on J9 except for tests.api.java.net.JarURLConnectionTest on Windows
XP
Classlin LUNI tests all passed on DRLVM on Windows XP


Added:
    harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/Process2Test.java
  (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/process/SystemProcess.java
    harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Runtime.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/process/SystemProcess.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/process/SystemProcess.java?view=diff&rev=501584&r1=501583&r2=501584
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/process/SystemProcess.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/internal/process/SystemProcess.java
Tue Jan 30 13:43:51 2007
@@ -17,6 +17,8 @@
 
 package org.apache.harmony.luni.internal.process;
 
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
@@ -89,9 +91,9 @@
                     return;
                 }
                 p.handle = procVals[0];
-                p.in = new ProcessOutputStream(procVals[1]);
-                p.out = new ProcessInputStream(procVals[2]);
-                p.err = new ProcessInputStream(procVals[3]);
+                p.in = new BufferedOutputStream(new ProcessOutputStream(procVals[1]));
+                p.out = new BufferedInputStream(new ProcessInputStream(procVals[2]));
+                p.err = new BufferedInputStream(new ProcessInputStream(procVals[3]));
 
                 synchronized (p.lock) {
                     p.waiterStarted = true;

Added: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/Process2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/Process2Test.java?view=auto&rev=501584
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/Process2Test.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/Process2Test.java
Tue Jan 30 13:43:51 2007
@@ -0,0 +1,53 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+
+package tests.api.java.lang;
+
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import tests.support.Support_Exec;
+
+public class Process2Test extends junit.framework.TestCase {
+	/**
+	 * @tests java.lang.Process#getInputStream(), 
+	 *        java.lang.Process#getErrorStream()
+	 *        java.lang.Process#getOutputStream()
+	 * Tests if these methods return buffered streams.
+	 */
+	public void test_isBufferedStreams() {
+		// Regression test for HARMONY-2735.
+		try {
+			Object[] execArgs = Support_Exec.execJava2(new String[0], null, true);
+			Process p = (Process) execArgs[0];
+			InputStream in = p.getInputStream();
+                  assertTrue("getInputStream() returned non-buffered stream: " + in, (in
instanceof BufferedInputStream));
+                  in = p.getErrorStream();
+                  assertTrue("getErrorStream() returned non-buffered stream: " + in, (in
instanceof BufferedInputStream));
+                  OutputStream out = p.getOutputStream();
+                  assertTrue("getOutputStream() returned non-buffered stream: " + out, (out
instanceof BufferedOutputStream));
+                  in.close();
+                  out.close();
+                  p.destroy();
+		} catch (Exception ex) {
+			fail("Unexpected exception got: " + ex);
+		}
+	}
+}

Propchange: harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/lang/Process2Test.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Runtime.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Runtime.java?view=diff&rev=501584&r1=501583&r2=501584
==============================================================================
--- harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Runtime.java
(original)
+++ harmony/enhanced/drlvm/trunk/vm/vmcore/src/kernel_classes/javasrc/java/lang/Runtime.java
Tue Jan 30 13:43:51 2007
@@ -38,6 +38,8 @@
 package java.lang;
 
 import java.util.StringTokenizer;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
 import java.io.File;
 import java.io.InputStream;
 import java.io.OutputStream;
@@ -256,9 +258,9 @@
 
         private int processHandle;
         private int processExitCode;
-        private SubProcess.SubOutputStream os;
-        private SubProcess.SubInputStream is;
-        private SubProcess.SubInputStream es;
+        private OutputStream os;
+        private InputStream is;
+        private InputStream es;
 
         /**
          * An application cannot create its own instance of this class.
@@ -307,9 +309,9 @@
             // Do all java heap allocation first, in order to throw OutOfMemory
             // exception early, before we have actually executed the process.
             // Otherwise we should do somewhat complicated cleanup.
-            os = new SubProcess.SubOutputStream();
-            is = new SubProcess.SubInputStream();
-            es = new SubProcess.SubInputStream();
+            SubProcess.SubOutputStream os1 = new SubProcess.SubOutputStream();
+            SubProcess.SubInputStream is1 = new SubProcess.SubInputStream();
+            SubProcess.SubInputStream es1 = new SubProcess.SubInputStream();
 
             long[] la = new long[4];
             createProcess0(cmdarray, envp, dir, la);
@@ -325,9 +327,12 @@
                 throw new IOException("The creation of the Process has just failed: " + cmd);

             }
             this.processHandle = (int)la[0];
-            os.streamHandle = la[1];
-            is.streamHandle = la[2];
-            es.streamHandle = la[3];
+            os1.streamHandle = la[1];
+            is1.streamHandle = la[2];
+            es1.streamHandle = la[3];
+            os = new BufferedOutputStream(os1);
+            is = new BufferedInputStream(is1);
+            es = new BufferedInputStream(es1);
         }
 
         /**



Mime
View raw message