You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "jeroen (Jira)" <ji...@apache.org> on 2023/06/07 07:10:00 UTC
[jira] [Commented] (IO-799) [ReaderInputStream] Repeated calls to read() while EOF should keep returning -1
[ https://issues.apache.org/jira/browse/IO-799?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17729977#comment-17729977 ]
jeroen commented on IO-799:
---------------------------
Reproduction:
{code:java}
public static void main(String[] args) throws IOException {
try (ReaderInputStream reader = ReaderInputStream.builder().setCharset(StandardCharsets.UTF_8).setReader(new StringReader("123")).get()) {
System.out.println(reader.read());
System.out.println(reader.read());
System.out.println(reader.read());
System.out.println(reader.read());
System.out.println(reader.read()); // This throws the exception.
}
} {code}
> [ReaderInputStream] Repeated calls to read() while EOF should keep returning -1
> -------------------------------------------------------------------------------
>
> Key: IO-799
> URL: https://issues.apache.org/jira/browse/IO-799
> Project: Commons IO
> Issue Type: Improvement
> Components: Streams/Writers
> Affects Versions: 2.12.0
> Environment: Ubuntu x64, Java 11.
> Reporter: jeroen
> Priority: Major
>
> Once a ReaderInputStream reaches the end of the input, it only returns -1 once. Subsequent calls to read() throw an IllegalStateException. This undocumented and unexpected.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)