RFR: 8279283 - BufferedInputStream should override transferTo [v7]

Daniel Fuchs dfuchs at openjdk.org
Mon Sep 5 20:26:59 UTC 2022


On Mon, 5 Sep 2022 18:05:04 GMT, Markus KARG <duke at openjdk.org> wrote:

>> Implementation of JDK-8279283
>
> Markus KARG has updated the pull request incrementally with one additional commit since the last revision:
> 
>   HexPrinter::transferTo

test/lib/jdk/test/lib/hexdump/HexPrinter.java line 1194:

> 1192:             byteOffset += size;
> 1193:             return size;
> 1194:         }

This is an indication that overriding `transferTo()` in `BufferedInputStream` has potential compatibility impacts on its subclasses. Therefore I would suggest adding a check in `BufferedInputStream::transferTo` to only override the behavior if not subclassed. Something like:


     if (this.getClass() != BufferedInputStream.class) {
         // a custom subclass may have expectations on which
         // methods tansferTo() will call. Revert to super class
         // behavior for compatibility.
         return super.transferTo(out);
     }
     ... otherwise proceed with the new implementation ...


Then you can revert the changes in this test.

-------------

PR: https://git.openjdk.org/jdk/pull/6935


More information about the core-libs-dev mailing list