RFR: JDK-8294702 - BufferedInputStream uses undefined value range for markpos
Markus KARG
duke at openjdk.org
Tue Oct 4 15:48:29 UTC 2022
On Tue, 4 Oct 2022 06:55:11 GMT, Alan Bateman <alanb at openjdk.org> wrote:
>> Fixes JDK-8294702
>
> src/java.base/share/classes/java/io/BufferedInputStream.java line 546:
>
>> 544: private void implReset() throws IOException {
>> 545: getBufIfOpen(); // Cause exception if closed
>> 546: if (markpos == -1)
>
> Just looking at this one again and it might be better to not change implReset. If a broken subclass were to set markpos to less than -1 then the reset() method would throw and avoid a more confusing IIOOBE or other exception.
This is true, but if a broken subclass sets markpos to less than -1 then lots of code lines will work incorrectly -- including `transferTo` which was the starting point of your change proposal. So do you really only want undo the change *here*, or is it better drop this PR and even use `< 0` in `transferTo`, as I originally proposed?
-------------
PR: https://git.openjdk.org/jdk/pull/10528
More information about the core-libs-dev
mailing list