RFR: 8233451: (fs) Files.newInputStream() cannot be used with character special files

Archie Cobbs acobbs at openjdk.org
Tue Oct 15 15:06:10 UTC 2024


On Mon, 14 Oct 2024 23:30:06 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> Add `isOther` and `available` methods to `FileChannelImpl` and the interfaces to native code and use these in `ChannelInputStream` to work around cases where a wrapped `FileChannelImpl` is not really seekable.

Albeit with my very basic understanding of these internals, it seems wrong that the `FileChannel` created to represent a special ends up also being a `SeekableFileChannel`. This seems like the true root of the problem - that is, the fact that these files are being labeled as seekable but they're not actually seekable is what leads to the bug.

The approach also this leads to the requirement for "fixups" like these, which are brittle and kindof a red flag that something is not quite right:

if (!(ch instanceof SeekableByteChannel sbc) ||
     (ch instanceof FileChannelImpl fci && isOther()))


In other words, we already have an interface for representing exactly this situation, so why not use it? What is the rationale for not doing so? I'm not saying there isn't one, just seeking to better understand the trade-offs...

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

PR Comment: https://git.openjdk.org/jdk/pull/21508#issuecomment-2414194787


More information about the core-libs-dev mailing list