harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r889194 [2/2] - in /harmony/enhanced/classlib/branches/java6: ./ make/ modules/archive/src/main/java/java/util/jar/ modules/archive/src/main/java/java/util/zip/ modules/concurrent/src/main/java/java/util/concurrent/atomic/ modules/concurren...
Date Thu, 10 Dec 2009 11:24:05 GMT
Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/utils/JarUtils.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/utils/JarUtils.java?rev=889194&r1=889193&r2=889194&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/utils/JarUtils.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/main/java/common/org/apache/harmony/security/utils/JarUtils.java
Thu Dec 10 11:23:50 2009
@@ -38,7 +38,6 @@
 
 import javax.security.auth.x500.X500Principal;
 
-import org.apache.harmony.luni.util.InputStreamHelper;
 import org.apache.harmony.security.asn1.BerInputStream;
 import org.apache.harmony.security.internal.nls.Messages;
 import org.apache.harmony.security.pkcs7.ContentInfo;
@@ -145,7 +144,8 @@
         // Otherwise, compute the message digest on the data.
         List atr = sigInfo.getAuthenticatedAttributes();
 
-        byte[] sfBytes = InputStreamHelper.readFullyAndClose(signature);
+        byte[] sfBytes = new byte[signature.available()];
+        signature.read(sfBytes);
 
         if (atr == null) {
             sig.update(sfBytes);    

Modified: harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureClassLoader2Test.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureClassLoader2Test.java?rev=889194&r1=889193&r2=889194&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureClassLoader2Test.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/security/src/test/api/java/org/apache/harmony/security/tests/java/security/SecureClassLoader2Test.java
Thu Dec 10 11:23:50 2009
@@ -17,6 +17,7 @@
 
 package org.apache.harmony.security.tests.java.security;
 
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
@@ -28,8 +29,6 @@
 import java.util.Enumeration;
 import java.util.jar.JarFile;
 
-import org.apache.harmony.luni.util.InputStreamHelper;
-
 import tests.support.Support_GetLocal;
 
 public class SecureClassLoader2Test extends junit.framework.TestCase {
@@ -62,11 +61,47 @@
 
         File file = Support_GetLocal.getLocalFile("hyts_security.jar");
         JarFile jar = new JarFile(file);
-        InputStream in = jar.getInputStream(jar.getEntry("packA/SecurityTest.class"));
-        byte[] bytes = InputStreamHelper.readFullyAndClose(in);
+        InputStream in = jar.getInputStream(jar
+                .getEntry("packA/SecurityTest.class"));
+        byte[] bytes = drain(in);
         Class c = myloader.define("packA.SecurityTest", bytes);
 		ProtectionDomain pd = c.getProtectionDomain();
 		assertNotNull("Expected dynamic policy", pd.getClassLoader());
 		assertNull("Expected null permissions", pd.getPermissions());
 	}
+
+    /*
+     * Drains the entire content from the given input stream and returns it as a
+     * byte[]. The stream is closed after being drained, or if an IOException
+     * occurs.
+     */
+    private byte[] drain(InputStream is) throws IOException {
+        try {
+            // Initial read
+            byte[] buffer = new byte[1024];
+            int count = is.read(buffer);
+            int nextByte = is.read();
+
+            // Did we get it all in one read?
+            if (nextByte == -1) {
+                byte[] dest = new byte[count];
+                System.arraycopy(buffer, 0, dest, 0, count);
+                return dest;
+            }
+
+            // Requires additional reads
+            ByteArrayOutputStream baos = new ByteArrayOutputStream(count * 2);
+            baos.write(buffer, 0, count);
+            baos.write(nextByte);
+            while (true) {
+                count = is.read(buffer);
+                if (count == -1) {
+                    return baos.toByteArray();
+                }
+                baos.write(buffer, 0, count);
+            }
+        } finally {
+            is.close();
+        }
+    }
 }
\ No newline at end of file

Modified: harmony/enhanced/classlib/branches/java6/modules/sound/src/main/java/org/apache/harmony/sound/utils/ProviderService.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sound/src/main/java/org/apache/harmony/sound/utils/ProviderService.java?rev=889194&r1=889193&r2=889194&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/sound/src/main/java/org/apache/harmony/sound/utils/ProviderService.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/sound/src/main/java/org/apache/harmony/sound/utils/ProviderService.java
Thu Dec 10 11:23:50 2009
@@ -17,11 +17,12 @@
 
 package org.apache.harmony.sound.utils;
 
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
+import java.io.InputStream;
 import java.io.FileNotFoundException;
 import java.io.IOException;
-import java.io.InputStream;
 import java.net.URL;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
@@ -30,8 +31,6 @@
 import java.util.List;
 import java.util.Properties;
 
-import org.apache.harmony.luni.util.InputStreamHelper;
-
 public class ProviderService {
 
     // Properties from sound.propertie file
@@ -146,7 +145,7 @@
                             try {
                                 InputStream in = urls.nextElement()
                                         .openStream();
-                                bytes = InputStreamHelper.readFullyAndClose(in);
+                                bytes = getAllBytesFromStreamAndClose(in);
                             } catch (IOException e) {
                                 continue;
                             }
@@ -173,5 +172,41 @@
     public static Properties getSoundProperties() {
         return devices;
     }
+    
+    /*
+     * Drains the entire content from the given input stream and returns it as a
+     * byte[]. The stream is closed after being drained, or if an IOException
+     * occurs.
+     */
+    private static byte[] getAllBytesFromStreamAndClose(InputStream is)
+            throws IOException {
+        try {
+            // Initial read
+            byte[] buffer = new byte[512];
+            int count = is.read(buffer);
+            int nextByte = is.read();
+
+            // Did we get it all in one read?
+            if (nextByte == -1) {
+                byte[] dest = new byte[count];
+                System.arraycopy(buffer, 0, dest, 0, count);
+                return dest;
+            }
+
+            // Requires additional reads
+            ByteArrayOutputStream baos = new ByteArrayOutputStream(count * 2);
+            baos.write(buffer, 0, count);
+            baos.write(nextByte);
+            while (true) {
+                count = is.read(buffer);
+                if (count == -1) {
+                    return baos.toByteArray();
+                }
+                baos.write(buffer, 0, count);
+            }
+        } finally {
+            is.close();
+        }
+    }
 
 }

Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLExceptionTest.java?rev=889194&r1=889193&r2=889194&view=diff
==============================================================================
Files harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLExceptionTest.java
(original) and harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLExceptionTest.java
Thu Dec 10 11:23:50 2009 differ

Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLWarningTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLWarningTest.java?rev=889194&r1=889193&r2=889194&view=diff
==============================================================================
Files harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLWarningTest.java
(original) and harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/java/sql/SQLWarningTest.java
Thu Dec 10 11:23:50 2009 differ

Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/transaction/TransactionRequiredExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/transaction/TransactionRequiredExceptionTest.java?rev=889194&r1=889193&r2=889194&view=diff
==============================================================================
Files harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/transaction/TransactionRequiredExceptionTest.java
(original) and harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/transaction/TransactionRequiredExceptionTest.java
Thu Dec 10 11:23:50 2009 differ

Modified: harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/transaction/TransactionRolledbackExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/transaction/TransactionRolledbackExceptionTest.java?rev=889194&r1=889193&r2=889194&view=diff
==============================================================================
Files harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/transaction/TransactionRolledbackExceptionTest.java
(original) and harmony/enhanced/classlib/branches/java6/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/transaction/TransactionRolledbackExceptionTest.java
Thu Dec 10 11:23:50 2009 differ

Propchange: harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/BasicSwingTestCase.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 10 11:23:50 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/BasicSwingTestCase.java:768152-889062
+/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/BasicSwingTestCase.java:768152-885602

Propchange: harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/SwingTestCase.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 10 11:23:50 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/SwingTestCase.java:768152-889062
+/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/SwingTestCase.java:768152-885602

Propchange: harmony/enhanced/classlib/branches/java6/modules/swing/src/test/api/java.injected/javax/swing/text/parser/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Dec 10 11:23:50 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/parser:768152-889062
+/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/parser:768152-885602



Mime
View raw message