Marcono1234 commented on a change in pull request #291:
URL: https://github.com/apache/commons-io/pull/291#discussion_r748648571



##########
File path: src/main/java/org/apache/commons/io/input/ReaderInputStream.java
##########
@@ -213,6 +230,16 @@ public void close() throws IOException {
         reader.close();
     }
 
+    /**
+     * The implementation by {@link ReaderInputStream} always returns 0.
+     */
+    @Override
+    public int available() throws IOException {
+        // Could implement this using Reader.ready(), but would be rather 
cumbersome
+        // and probably not very efficient
+        return 0;
+    }
+

Review comment:
       This class directly extends `InputStream` and the 
[`InputStream.available()` 
documentation](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/InputStream.html#available())
 says:
   > The available method of InputStream always returns 0.
   
   I could have used `return super.available();` instead, but then it would be 
less obvious to the reader why the documentation of this method here says that 
it always returns 0 but calls `super.available()`. So I wanted to avoid 
requiring them to look up the super implementation to verify that this method 
behaves correctly.




-- 
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-unsubscr...@commons.apache.org

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


Reply via email to