commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject [1/2] commons-compress git commit: COMPRESS-412 NullPointerException defect in ChecksumCalculatingInputStream#getValue() fixed.
Date Sat, 17 Jun 2017 18:35:01 GMT
Repository: commons-compress
Updated Branches:
  refs/heads/master b53ead4b4 -> 8c3201bbd


COMPRESS-412 NullPointerException defect in ChecksumCalculatingInputStream#getValue() fixed.


Project: http://git-wip-us.apache.org/repos/asf/commons-compress/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-compress/commit/6f379134
Tree: http://git-wip-us.apache.org/repos/asf/commons-compress/tree/6f379134
Diff: http://git-wip-us.apache.org/repos/asf/commons-compress/diff/6f379134

Branch: refs/heads/master
Commit: 6f379134ae1807cd404ed6c9579707e5dc6a6df0
Parents: b53ead4
Author: Michael Hausegger <michael.hausegger@tugraz.at>
Authored: Fri Jun 16 21:30:03 2017 +0200
Committer: Stefan Bodewig <bodewig@apache.org>
Committed: Sat Jun 17 20:29:37 2017 +0200

----------------------------------------------------------------------
 .../utils/ChecksumCalculatingInputStream.java   |  9 +++++++
 .../ChecksumCalculatingInputStreamTest.java     | 26 ++++++++++++++++++++
 2 files changed, 35 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/commons-compress/blob/6f379134/src/main/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStream.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStream.java
b/src/main/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStream.java
index ebf44fd..4a408a5 100644
--- a/src/main/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStream.java
+++ b/src/main/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStream.java
@@ -31,6 +31,15 @@ public class ChecksumCalculatingInputStream extends InputStream {
     private final Checksum checksum;
 
     public ChecksumCalculatingInputStream(final Checksum checksum, final InputStream in)
{
+
+        if ( checksum == null ){
+            throw new NullPointerException("Parameter checksum must not be null");
+        }
+
+        if ( in == null ){
+            throw new NullPointerException("Parameter in must not be null");
+        }
+
         this.checksum = checksum;
         this.in = in;
     }

http://git-wip-us.apache.org/repos/asf/commons-compress/blob/6f379134/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java
b/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java
index b97b09e..a9e5246 100644
--- a/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java
+++ b/src/test/java/org/apache/commons/compress/utils/ChecksumCalculatingInputStreamTest.java
@@ -22,6 +22,7 @@ import java.io.BufferedInputStream;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.util.zip.Adler32;
+import java.util.zip.CRC32;
 
 import static org.junit.Assert.*;
 
@@ -106,5 +107,30 @@ public class ChecksumCalculatingInputStreamTest {
     }
 
 
+    @Test(expected = NullPointerException.class)
+    public void testClassInstantiationWithParameterBeingNullThrowsNullPointerExceptionOne()
{
+
+        ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(null,null);
+
+
+    }
+
+
+    @Test(expected = NullPointerException.class)
+    public void testClassInstantiationWithParameterBeingNullThrowsNullPointerExceptionTwo()
{
+
+        ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(null,new
ByteArrayInputStream(new byte[1]));
+
+
+    }
+
+
+    @Test(expected = NullPointerException.class)
+    public void testClassInstantiationWithParameterBeingNullThrowsNullPointerExceptionThree()
{
+
+        ChecksumCalculatingInputStream checksumCalculatingInputStream = new ChecksumCalculatingInputStream(new
CRC32(),null);
+
+    }
+
 
 }
\ No newline at end of file


Mime
View raw message