RFR: 8274780: ChannelInputStream.readNBytes(int) incorrectly calls readAllBytes()

Brian Burkhalter bpb at openjdk.java.net
Tue Oct 5 17:05:12 UTC 2021


On Tue, 5 Oct 2021 14:46:26 GMT, Florian Weimer <fweimer at openjdk.org> wrote:

> 8274780: ChannelInputStream.readNBytes(int) incorrectly calls readAllBytes()

test/jdk/java/nio/channels/Channels/ReadXBytes.java line 160:

> 158:              ReadableByteChannel ch = Channels.newChannel(
> 159:                  new FilterInputStream(fis2) {});
> 160:              InputStream cis = Channels.newInputStream(ch)) {

With four resources in the `try`, this `try-with-resources` is a little hard to read. Perhaps use two nested `t-w-r`s instead?

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

PR: https://git.openjdk.java.net/jdk/pull/5824


More information about the nio-dev mailing list