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-io.git

commit dbba1ff6c4160c83aee6f0ac37b8d133bbf5e221
Author: Gary D. Gregory <garydgreg...@gmail.com>
AuthorDate: Thu Apr 3 10:37:43 2025 -0400

    Calling QueueInputStream.QueueInputStream(null) maps to the same kind of
    default blocking queue as
    QueueInputStream.Builder.setBlockingQueue(null)
---
 src/changes/changes.xml                               |  1 +
 .../org/apache/commons/io/input/QueueInputStream.java | 19 +++++++++----------
 .../apache/commons/io/input/QueueInputStreamTest.java |  1 -
 3 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index f62ceaffc..c690882d0 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -72,6 +72,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action dev="ggregory" type="fix"                due-to="Gary 
Gregory">FileTimes.toNtfsTime(*) methods can overflow result values.</action>
       <action dev="ggregory" type="fix"                due-to="Gary 
Gregory">Fix Javadoc for ChunkedOutputStream.Builder.</action>
       <action dev="ggregory" type="fix"                due-to="Gary 
Gregory">General Javadoc improvements.</action>
+      <action dev="ggregory" type="fix"                due-to="Gary 
Gregory">Calling QueueInputStream.QueueInputStream(null) maps to the same kind 
of default blocking queue as 
QueueInputStream.Builder.setBlockingQueue(null).</action>
       <!-- ADD -->
       <action dev="ggregory" type="add" issue="IO-860" due-to="Nico Strecker, 
Gary Gregory">Add ThrottledInputStream.Builder.setMaxBytes(long, 
ChronoUnit).</action>
       <action dev="ggregory" type="add"                due-to="Gary 
Gregory">Add IOIterable.</action>
diff --git a/src/main/java/org/apache/commons/io/input/QueueInputStream.java 
b/src/main/java/org/apache/commons/io/input/QueueInputStream.java
index d0d220554..cc72bc29d 100644
--- a/src/main/java/org/apache/commons/io/input/QueueInputStream.java
+++ b/src/main/java/org/apache/commons/io/input/QueueInputStream.java
@@ -106,13 +106,13 @@ public Builder() {
          */
         @Override
         public QueueInputStream get() {
-            return new QueueInputStream(blockingQueue, timeout);
+            return new QueueInputStream(this);
         }
 
         /**
          * Sets backing queue for the stream.
          *
-         * @param blockingQueue backing queue for the stream.
+         * @param blockingQueue backing queue for the stream, null resets to a 
new blocking queue instance.
          * @return {@code this} instance.
          */
         public Builder setBlockingQueue(final BlockingQueue<Integer> 
blockingQueue) {
@@ -160,23 +160,22 @@ public QueueInputStream() {
     /**
      * Constructs a new instance with given queue and zero timeout.
      *
-     * @param blockingQueue backing queue for the stream.
+     * @param blockingQueue backing queue for the stream, null maps to a new 
blocking queue instance.
      * @deprecated Use {@link #builder()}, {@link Builder}, and {@link 
Builder#get()}.
      */
     @Deprecated
     public QueueInputStream(final BlockingQueue<Integer> blockingQueue) {
-        this(blockingQueue, Duration.ZERO);
+        this(builder().setBlockingQueue(blockingQueue));
     }
 
     /**
-     * Constructs a new instance with given queue and timeout.
+     * Constructs a new instance.
      *
-     * @param blockingQueue backing queue for the stream.
-     * @param timeout       how long to wait before giving up when polling the 
queue.
+     * @param builder The builder.
      */
-    private QueueInputStream(final BlockingQueue<Integer> blockingQueue, final 
Duration timeout) {
-        this.blockingQueue = Objects.requireNonNull(blockingQueue, 
"blockingQueue");
-        this.timeoutNanos = Objects.requireNonNull(timeout, 
"timeout").toNanos();
+    private QueueInputStream(final Builder builder) {
+        this.blockingQueue = Objects.requireNonNull(builder.blockingQueue, 
"blockingQueue");
+        this.timeoutNanos = Objects.requireNonNull(builder.timeout, 
"timeout").toNanos();
     }
 
     /**
diff --git 
a/src/test/java/org/apache/commons/io/input/QueueInputStreamTest.java 
b/src/test/java/org/apache/commons/io/input/QueueInputStreamTest.java
index 9ee23214a..742698b5f 100644
--- a/src/test/java/org/apache/commons/io/input/QueueInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/QueueInputStreamTest.java
@@ -159,7 +159,6 @@ public void testBufferedWrites(final String inputData) 
throws IOException {
 
     @Test
     public void testInvalidArguments() {
-        assertThrows(NullPointerException.class, () -> new 
QueueInputStream(null), "queue is required");
         assertThrows(IllegalArgumentException.class, () -> 
QueueInputStream.builder().setTimeout(Duration.ofMillis(-1)).get(), "waitTime 
must not be negative");
     }
 

Reply via email to