You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "garydgregory (via GitHub)" <gi...@apache.org> on 2023/04/11 14:29:55 UTC

[GitHub] [commons-io] garydgregory commented on a diff in pull request #447: Add blocking read mode to QueueInputStream.

garydgregory commented on code in PR #447:
URL: https://github.com/apache/commons-io/pull/447#discussion_r1162907587


##########
src/main/java/org/apache/commons/io/input/QueueInputStream.java:
##########
@@ -86,12 +99,24 @@ public QueueOutputStream newQueueOutputStream() {
     }
 
     /**
-     * Reads and returns a single byte.
+     * Reads and returns a single byte. In blocking read mode, the method will wait if necessary until a queue element
+     * becomes available. In non-blocking read mode, the method will return -1 immediately if the queue is empty.
      *
      * @return either the byte read or {@code -1} if the end of the stream has been reached
+     * @throws InterruptedIOException if the thread is interrupted while reading from the queue.
      */
     @Override
-    public int read() {
+    public int read() throws InterruptedIOException {

Review Comment:
   -1; I'm not a fan of this style because it is the opposite of OO: For each char, we test and execute one branch or another _based on state that never changes_, which tells me this should be implemented either as a subclass or pluggable strategy (with a lambda for example).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@commons.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org