harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r441013 - in /incubator/harmony/enhanced/classlib/trunk/modules/crypto/src: main/java/javax/crypto/CipherInputStream.java test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherInputStreamTest.java
Date Thu, 07 Sep 2006 08:07:00 GMT
Author: mloenko
Date: Thu Sep  7 01:07:00 2006
New Revision: 441013

URL: http://svn.apache.org/viewvc?view=rev&rev=441013
Log:
applied patch for HARMONY-1087
[classlib][crypto] compatibility: RI throws IllegalStateException while Harmony IOException
(according to spec)

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

Modified: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/CipherInputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/CipherInputStream.java?view=diff&rev=441013&r1=441012&r2=441013
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/CipherInputStream.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/main/java/javax/crypto/CipherInputStream.java
Thu Sep  7 01:07:00 2006
@@ -25,6 +25,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import javax.crypto.NullCipher;
+import java.security.GeneralSecurityException;
 
 /**
  * @com.intel.drl.spec_ref
@@ -138,6 +139,12 @@
      */
     public void close() throws IOException {
         in.close();
+        try {
+            cipher.doFinal();
+        } catch (GeneralSecurityException e) {
+            throw (IOException) new IOException(e.getMessage()).initCause(e);
+        }
+
     }
 
     /**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherInputStreamTest.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/CipherInputStreamTest.java?view=diff&rev=441013&r1=441012&r2=441013
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherInputStreamTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherInputStreamTest.java
Thu Sep  7 01:07:00 2006
@@ -16,7 +16,13 @@
 
 package org.apache.harmony.crypto.tests.javax.crypto;
 
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
 import junit.framework.TestCase;
+
+import javax.crypto.Cipher;
 import javax.crypto.CipherInputStream;
 import javax.crypto.NullCipher;
 
@@ -35,4 +41,26 @@
             // expected
         }
     }
+
+    /**
+     * @tests javax.crypto.CipherInputStream#close()
+     */
+    public void testClose() throws Exception {
+        // Regression for HARMONY-1087
+        try {
+            new CipherInputStream(new ByteArrayInputStream(new byte[] { 1 }),
+                    Cipher.getInstance("DES/CBC/PKCS5Padding")).close();
+            fail("IllegalStateException expected!");
+        } catch (IllegalStateException e) {
+            // expected
+        }
+        try {
+            new CipherInputStream(new BufferedInputStream((InputStream) null),
+                    Cipher.getInstance("DES/CBC/PKCS5Padding")).close();
+            fail("IllegalStateException expected!");
+        } catch (IllegalStateException e) {
+            // expected
+        }
+    }
+
 }



Mime
View raw message