RFR: 8341566: Adding factory for non-synchronized CharSequence Reader [v3]
Markus KARG
duke at openjdk.org
Tue Oct 8 11:29:05 UTC 2024
On Sun, 6 Oct 2024 18:25:15 GMT, Bernd <duke at openjdk.org> wrote:
>> src/java.base/share/classes/java/io/Reader.java line 231:
>>
>>> 229: public boolean ready() throws IOException {
>>> 230: ensureOpen();
>>> 231: return true;
>>
>> I guess it’s not wrong, but can this be false when end of source is reached? Related to this you already described it is not synchronized but should we also describe it does not support changes to the length during “iteration” (could be in the same thread).
>
> Ignore my “thinko”/comment. of course it needs to return true for the EOD.
>From `Reader.ready()`'s JavaDocs:
>True if the next read() is guaranteed not to **block** for input, false otherwise. Note that returning false does not guarantee that the next read will **block**.
`ready()` says that it will not **block**. The current proposal will *never block*. So it is correct to return `true` *always*, even in case of EOL. There is nothing we need to explicitly describe here.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/21371#discussion_r1791503407
More information about the core-libs-dev
mailing list