JDK-4648049 : (ch) Stream adaptors do not usefully implement available()
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: generic,solaris_7
  • CPU: generic,x86
  • Submitted: 2002-03-06
  • Updated: 2019-05-07
  • Resolved: 2019-05-07
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
tbdResolved
Related Reports
Duplicate :  
Relates :  
Relates :  
Description
The following always return 0 as the implementation of available()
needs to be overridden :-

Channels.newInputStream(ch).available()
sc.socket().getInputStream().available()

Comments
This was fixed within JDK-8222774, so that now InputStream implementation delegates to available() of underlying SocketChannel.
07-05-2019

EVALUATION The available() method was updated in jdk7 to be useful with files, see 6884800.
07-01-2012

EVALUATION The current behaviors satisfy the specification of the InputStream.available() method, though they're admittedly not as useful as "real" implementations of this method would be. In the general case of the Channels.newInputStream(ch) method: Implementing available() in the objects returned by this factory requires adding functionality to the channel interfaces. Hence this must wait until the next feature release. In the specific case of the streams returned by sc.socket().getInputStream(): If absolutely necessary we could add special-case native code for these without having to change any public APIs. -- ###@###.### 2002/3/6
03-10-0172