harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r440022 - 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 Mon, 04 Sep 2006 10:39:59 GMT
Author: mloenko
Date: Mon Sep  4 03:39:57 2006
New Revision: 440022

URL: http://svn.apache.org/viewvc?view=rev&rev=440022
Log:
applied patch for HARMONY-1080
[classlib][crypto] compatibility: Harmony CipherInputStream().read(..) returns 0 while RI
throws NPE
with minor fixes

Added:
    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

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=440022&r1=440021&r2=440022
==============================================================================
--- 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
Mon Sep  4 03:39:57 2006
@@ -94,6 +94,10 @@
      * @com.intel.drl.spec_ref
      */
     public int read(byte[] b, int off, int len) throws IOException {
+        if (in == null) {
+            throw new NullPointerException("Underlying input stream is null");
+        }
+
         int read_b;
         int i;
         for (i=0; i<len; i++) {

Added: 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=auto&rev=440022
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherInputStreamTest.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/crypto/src/test/api/java/org/apache/harmony/crypto/tests/javax/crypto/CipherInputStreamTest.java
Mon Sep  4 03:39:57 2006
@@ -0,0 +1,38 @@
+/*
+ *  Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
+ *
+ *  Licensed 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 org.apache.harmony.crypto.tests.javax.crypto;
+
+import junit.framework.TestCase;
+import javax.crypto.CipherInputStream;
+import javax.crypto.NullCipher;
+
+public class CipherInputStreamTest extends TestCase {
+
+    /**
+     * @tests javax.crypto.CipherInputStream#read(byte[] b, int off, int len)
+     */
+    public void testReadBII() throws Exception {
+        // Regression for HARMONY-1080
+        CipherInputStream stream = new CipherInputStream(null, new NullCipher());
+        try {
+            stream.read(new byte[1], 1, 0);
+            fail("NullPointerException expected");
+        } catch (NullPointerException e) {
+            // expected
+        }
+    }
+}



Mime
View raw message