harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r463187 - in /incubator/harmony/enhanced/classlib/trunk/modules/crypto/src: main/java/javax/crypto/CipherOutputStream.java test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherOutputStreamTest.java
Date Thu, 12 Oct 2006 11:03:13 GMT
Author: mloenko
Date: Thu Oct 12 04:03:11 2006
New Revision: 463187

URL: http://svn.apache.org/viewvc?view=rev&rev=463187
Log:
refixed HARMONY-1139
[classlib][crypto] compatibility: CipherOutputStream().close() throws the IllegalStateException
on RI and the NPE on Harmony

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/CipherOutputStream.java
    incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherOutputStreamTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/CipherOutputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/CipherOutputStream.java?view=diff&rev=463187&r1=463186&r2=463187
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/CipherOutputStream.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/CipherOutputStream.java
Thu Oct 12 04:03:11 2006
@@ -95,9 +95,14 @@
     public void close() throws IOException {
         byte[] result;
         try {
-            result = cipher.doFinal();
-            if (result != null) {
-                out.write(result);
+            if (cipher != null) {
+                result = cipher.doFinal();
+                if (result != null) {
+                    out.write(result);
+                }
+            }
+            if (out != null) {
+                out.flush();
             }
         } catch (BadPaddingException e) {
             throw new IOException(e.getMessage());
@@ -105,7 +110,6 @@
             throw new IOException(e.getMessage());
         } finally {
             if (out != null) {
-                out.flush();
                 out.close();
             }
         }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherOutputStreamTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherOutputStreamTest.java?view=diff&rev=463187&r1=463186&r2=463187
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherOutputStreamTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherOutputStreamTest.java
Thu Oct 12 04:03:11 2006
@@ -31,7 +31,16 @@
                     .getInstance("DES/CBC/PKCS5Padding")).close();
             fail("IllegalStateException expected");
         } catch (IllegalStateException e) {
-            //expected
+            // expected
+        }
+
+        CipherOutputStream ch = new CipherOutputStream((OutputStream) null) {};
+        try {
+            new CipherOutputStream(ch, Cipher
+                    .getInstance("DES/CBC/PKCS5Padding")).close();
+            fail("IllegalStateException expected");
+        } catch (IllegalStateException e) {
+            // expected
         }
     }
 }



Mime
View raw message