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


The following commit(s) were added to refs/heads/master by this push:
     new 7be5b592 Add tests
7be5b592 is described below

commit 7be5b5921b7b65e6d50413f73872341cbb557e6a
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Sat Apr 22 09:35:21 2023 -0400

    Add tests
---
 .../apache/commons/io/input/QueueInputStream.java    | 20 +++++++++++++++++++-
 .../commons/io/input/QueueInputStreamTest.java       | 12 ++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)

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 bb9e0a07..bcbf79f5 100644
--- a/src/main/java/org/apache/commons/io/input/QueueInputStream.java
+++ b/src/main/java/org/apache/commons/io/input/QueueInputStream.java
@@ -81,7 +81,7 @@ public class QueueInputStream extends InputStream {
         private Duration timeout = Duration.ZERO;
 
         @Override
-        public QueueInputStream get() throws IOException {
+        public QueueInputStream get() {
             return new QueueInputStream(blockingQueue, timeout);
         }
 
@@ -153,6 +153,24 @@ public class QueueInputStream extends InputStream {
         this.timeoutMillis = Objects.requireNonNull(timeout, 
"timeout").toMillis();
     }
 
+    /**
+     * Gets the blocking queue.
+     *
+     * @return the blocking queue.
+     */
+    BlockingQueue<Integer> getBlockingQueue() {
+        return blockingQueue;
+    }
+
+    /**
+     * Gets the timeout duration.
+     *
+     * @return the timeout duration.
+     */
+    Duration getTimeout() {
+        return Duration.ofMillis(timeoutMillis);
+    }
+
     /**
      * Creates a new QueueOutputStream instance connected to this. Writes to 
the output stream will be visible to this input stream.
      *
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 3943c1db..e42db56f 100644
--- a/src/test/java/org/apache/commons/io/input/QueueInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/QueueInputStreamTest.java
@@ -139,6 +139,18 @@ public class QueueInputStreamTest {
         assertThrows(IllegalArgumentException.class, () -> 
QueueInputStream.builder().setTimeout(Duration.ofMillis(-1)).get(), "waitTime 
must not be negative");
     }
 
+    @Test
+    public void testResetArguments() throws IOException {
+        try (QueueInputStream queueInputStream = 
QueueInputStream.builder().setTimeout(null).get()) {
+            assertEquals(Duration.ZERO, queueInputStream.getTimeout());
+            assertEquals(0, queueInputStream.getBlockingQueue().size());
+        }
+        try (QueueInputStream queueInputStream = 
QueueInputStream.builder().setBlockingQueue(null).get()) {
+            assertEquals(Duration.ZERO, queueInputStream.getTimeout());
+            assertEquals(0, queueInputStream.getBlockingQueue().size());
+        }
+    }
+
     @Test
     @DisplayName("If read is interrupted while waiting, then exception is 
thrown")
     public void testTimeoutInterrupted() throws Exception {

Reply via email to