harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ton...@apache.org
Subject svn commit: r889068 [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 03:22:42 GMT
Modified: harmony/enhanced/classlib/branches/java6/modules/rmi/src/main/java/java/rmi/server/RMIClassLoader.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/rmi/src/main/java/java/rmi/server/RMIClassLoader.java?rev=889068&r1=889067&r2=889068&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/rmi/src/main/java/java/rmi/server/RMIClassLoader.java
(original)
+++ harmony/enhanced/classlib/branches/java6/modules/rmi/src/main/java/java/rmi/server/RMIClassLoader.java
Thu Dec 10 03:22:37 2009
@@ -29,6 +29,7 @@
 import java.security.AccessController;
 import java.security.PrivilegedAction;
 
+import org.apache.harmony.luni.util.InputStreamHelper;
 import org.apache.harmony.rmi.DefaultRMIClassLoaderSpi;
 import org.apache.harmony.rmi.internal.nls.Messages;
 
@@ -210,9 +211,7 @@
             // resource not found
             return null;
         }
-        Object obj = null;
-        byte[] buf = new byte[in.available()];
-        in.read(buf);
+        byte[] buf = InputStreamHelper.readFullyAndClose(in);
         String str = new String(buf, "UTF-8"); //$NON-NLS-1$
         StringTokenizer tok = new StringTokenizer(str, "\n\r"); //$NON-NLS-1$
 

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=889068&r1=889067&r2=889068&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 03:22:37 2009
@@ -38,6 +38,7 @@
 
 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;
@@ -144,8 +145,7 @@
         // Otherwise, compute the message digest on the data.
         List atr = sigInfo.getAuthenticatedAttributes();
 
-        byte[] sfBytes = new byte[signature.available()];
-        signature.read(sfBytes);
+        byte[] sfBytes = InputStreamHelper.readFullyAndClose(signature);
 
         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=889068&r1=889067&r2=889068&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 03:22:37 2009
@@ -17,7 +17,6 @@
 
 package org.apache.harmony.security.tests.java.security;
 
-import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
@@ -29,6 +28,8 @@
 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 {
@@ -61,47 +62,11 @@
 
         File file = Support_GetLocal.getLocalFile("hyts_security.jar");
         JarFile jar = new JarFile(file);
-        InputStream in = jar.getInputStream(jar
-                .getEntry("packA/SecurityTest.class"));
-        byte[] bytes = drain(in);
+        InputStream in = jar.getInputStream(jar.getEntry("packA/SecurityTest.class"));
+        byte[] bytes = InputStreamHelper.readFullyAndClose(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=889068&r1=889067&r2=889068&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 03:22:37 2009
@@ -17,12 +17,11 @@
 
 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;
@@ -31,6 +30,8 @@
 import java.util.List;
 import java.util.Properties;
 
+import org.apache.harmony.luni.util.InputStreamHelper;
+
 public class ProviderService {
 
     // Properties from sound.propertie file
@@ -145,7 +146,7 @@
                             try {
                                 InputStream in = urls.nextElement()
                                         .openStream();
-                                bytes = getAllBytesFromStreamAndClose(in);
+                                bytes = InputStreamHelper.readFullyAndClose(in);
                             } catch (IOException e) {
                                 continue;
                             }
@@ -172,41 +173,5 @@
     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=889068&r1=889067&r2=889068&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 03:22:37 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=889068&r1=889067&r2=889068&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 03:22:37 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=889068&r1=889067&r2=889068&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 03:22:37 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=889068&r1=889067&r2=889068&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 03:22:37 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 03:22:37 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/BasicSwingTestCase.java:768152-885602
+/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/BasicSwingTestCase.java:768152-889062

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 03:22:37 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/SwingTestCase.java:768152-885602
+/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/SwingTestCase.java:768152-889062

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 03:22:37 2009
@@ -1 +1 @@
-/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/parser:768152-885602
+/harmony/enhanced/classlib/trunk/modules/swing/src/test/api/java.injected/javax/swing/text/parser:768152-889062



Mime
View raw message