JDK-8021820 : Number of opened files used in select() is limited to 1024 [macosx]
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: os_x
  • CPU: generic
  • Submitted: 2013-07-29
  • Updated: 2014-03-07
  • Resolved: 2013-08-19
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.
JDK 7 JDK 8
7u60Fixed 8 b105Fixed
Related Reports
Duplicate :  
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
The number of opened files used in select() on MacOSX is limited to 1024 (FD_SETSIZE). 
The following  sequence can illustrate the problem:
1. Open 1023 files (use FileInputStream())
2. Create socket and try to read from it.
3. Get the following exception:
Exception in thread "main" java.net.SocketException: Invalid argument
	at java.net.SocketInputStream.socketRead0(Native Method)
	at java.net.SocketInputStream.read(SocketInputStream.java:150)
	at java.net.SocketInputStream.read(SocketInputStream.java:121)
	at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
	at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
	at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
	at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:633)
	at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:579)
	at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:604)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1322)
	at SelectFdsLimit.main(SelectFdsLimit.java:86)

Comments
Attached test /test/java/net/ServerSocket/SelectFdsLimit.java passed
07-03-2014

jdk8/tl changeset: http://hg.openjdk.java.net/jdk8/tl/rev/00dcfaa6bc01
19-08-2013

The select is used only in java.net (Search for USE_SELECT macro). Based on this - suggesting 'java.net' sub-component.
30-07-2013

The java.io code doesn't use select so we probably should be tracking this in another sub-component.
29-07-2013

The MacOSx JDK uses the select() system call to wait for events on FDs (instead of poll() ). By default the number of file descriptors to select() on is limited to 1024. To remove this limit the D_DARWIN_UNLIMITED_SELECT flag should be used during compilation.
29-07-2013