You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2023/10/22 13:15:40 UTC

[commons-crypto] 08/08: StreamOutput.StreamOutput(OutputStream, int) now throws NullPointerException on null input

This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-crypto.git

commit 5aa398e5c3cc693f7fc9b3659f29794c6632aa15
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Oct 22 09:15:16 2023 -0400

    StreamOutput.StreamOutput(OutputStream, int) now throws
    NullPointerException on null input
---
 src/changes/changes.xml                                             | 1 +
 .../java/org/apache/commons/crypto/stream/output/StreamOutput.java  | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 46f422e..1e2f167 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -75,6 +75,7 @@
       <action dev="ggregory"     type="fix" due-to="Gary Gregory">ChannelInput.ChannelInput(ReadableByteChannel) now throws NullPointerException on null input.</action>
       <action dev="ggregory"     type="fix" due-to="Gary Gregory">StreamInput.StreamInput(InputStream, int) now throws NullPointerException on null input.</action>
       <action dev="ggregory"     type="fix" due-to="Gary Gregory">ChannelOutput.ChannelOutput(WritableByteChannel) now throws NullPointerException on null input.</action>
+      <action dev="ggregory"     type="fix" due-to="Gary Gregory">StreamOutput.StreamOutput(OutputStream, int) now throws NullPointerException on null input.</action>
       <!-- UPDATE -->
       <action                    type="update" dev="ggregory" due-to="Dependabot, Gary Gregory">Bump commons-parent from 56 to 64 #225.</action>
       <action                    type="update" dev="ggregory" due-to="Gary Gregory">Bump com.sun.xml.bind:jaxb-impl from 2.3.7 to 2.3.8.</action>
diff --git a/src/main/java/org/apache/commons/crypto/stream/output/StreamOutput.java b/src/main/java/org/apache/commons/crypto/stream/output/StreamOutput.java
index 629be84..22fdce8 100644
--- a/src/main/java/org/apache/commons/crypto/stream/output/StreamOutput.java
+++ b/src/main/java/org/apache/commons/crypto/stream/output/StreamOutput.java
@@ -20,6 +20,7 @@ package org.apache.commons.crypto.stream.output;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.nio.ByteBuffer;
+import java.util.Objects;
 
 import org.apache.commons.crypto.stream.CryptoOutputStream;
 
@@ -38,11 +39,12 @@ public class StreamOutput implements Output {
      *
      * @param out the OutputStream object.
      * @param bufferSize the buffer size.
+     * @throws NullPointerException if channel is null.
      */
     public StreamOutput(final OutputStream out, final int bufferSize) {
-        this.out = out;
+        this.out = Objects.requireNonNull(out, "out");
         this.bufferSize = bufferSize;
-        buf = new byte[bufferSize];
+        this.buf = new byte[bufferSize];
     }
 
     /**