JDK-8274780 : ChannelInputStream.readNBytes(int) incorrectly calls readAllBytes()
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 18
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2021-10-05
  • Updated: 2021-10-05
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Related Reports
Relates :  
Description
JDK-8268435 contains a cut-and-paste error which calls readNBytes() from the readAllBytes() implementation:

        if (!(ch instanceof SeekableByteChannel sbc))
            return super.readAllBytes();

https://github.com/openjdk/jdk/commit/0786d8b7b367e3aa3ffa54a3e339572938378dca#diff-21e4ff89fd54955e45fcd085ae8c08033b6c92de7f98ab0c836d4f754117ececR171

Since IntputStream.readAllBytes() calls readNBytes() again, this results in a stack overflow (rather than incorrect data being returned).