JDK-6361557 : LightWeight http server quickly runs out of available file descriptors on linux.
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 6
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux,windows_xp
  • CPU: x86
  • Submitted: 2005-12-09
  • Updated: 2010-04-03
  • Resolved: 2006-03-23
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 6
6 b78Fixed
Related Reports
Duplicate :  
Description
Unpack the test attached.
Build with ant
run java -jar build/httpserver-bug.jar

The test runs HttpServer and invokes repeatingly the following code:

       javax.xml.ws.Service service = Service.create(URL,QNAME);
       Hello hello = service.getPort(Hello.class);
***//  hello.sayHello();

after a while the test starts throwing exceptions. The exceptions may be different, 
but command 
	ls -1 /proc/[pid of java]/fd | wc -l 
will return something near the maxopenfiles value. On my machine it is 1024

Also, if uncomment a line marked with stars, the test runs much longer before
exceptions will appear. Unfortunately in JAXWS tests we do not actually invoke web methods
in most cases.



====== Example of exception ==================
Unable to create StAX reader or writer
        at com.sun.xml.ws.streaming.XMLStreamReaderFactory.createFreshXMLStreamReader(XMLStreamReaderFactory.java:105)
        at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.createReader(RuntimeWSDLParser.java:140)
        at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parseWSDL(RuntimeWSDLParser.java:165)
        at com.sun.xml.ws.wsdl.parser.RuntimeWSDLParser.parse(RuntimeWSDLParser.java:62)
        at com.sun.xml.ws.wsdl.WSDLContext.<init>(WSDLContext.java:60)
        at com.sun.xml.ws.client.ServiceContextBuilder.build(ServiceContextBuilder.java:77)
        at com.sun.xml.ws.client.WSServiceDelegate.<init>(WSServiceDelegate.java:113)
        at com.sun.xml.ws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:50)
        at javax.xml.ws.Service.<init>(Service.java:58)
        at javax.xml.ws.Service.create(Service.java:302)
        at com.sun.testws.Test.execClient(Test.java:53)
        at com.sun.testws.Test.runTest(Test.java:43)
        at com.sun.testws.Test.main(Test.java:61)
Caused by: java.net.SocketException: Unexpected end of file from server
        at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:688)
        at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:558)
        at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:686)
        at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:558)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:970)
        at java.net.URL.openStream(URL.java:1007)
        at com.sun.xml.ws.streaming.XMLStreamReaderFactory.createFreshXMLStreamReader(XMLStreamReaderFactory.java:100)

Comments
EVALUATION I need to explain more about the attached code. The attached test: 1. Runs the single instance of Lightweight http server. 2. Starts to open the connections to this server in the loop using webservice client (javax.xml.ws.Service.create() calls corresponds to this) 3. Server creates too many open file descriptors that corresponds to opened sockets (ServerSocket.accept() retuns socket that require a file descriptor). Probably (but I'm not sure) the problem is that connections from web service client code are opened as 'keep-alive' connections, but server closes 'keep-alive' connections when timeout expires, but allows arbitrary number of such connections. To make absolutely clear what is going on, I have prepeared another example (attached: httpserverbug-2.jar). It contains: 1. web service implementation, deployable on both apache tomcat web server and lightweinght http server. 2. web service client 3. lightweight http server invoker that starts the server and deploys webservice to it Web service client does not contain any code that directly or indirectly runs lightweight http server. When webservice client runs with apache tomcat everything is ok. But it cannot run with lightweight http server even for a munute!
20-12-2005

EVALUATION I'm closing as not a bug
15-12-2005

EVALUATION This doesn't look like a bug to me. I'm not certain what Service.create() actually does but if it is creating a HttpServer instance, then opening a file-descriptor is what it is supposed to do. If you don't stop() the HttpServer after starting it, then the file descriptor does not get released.
13-12-2005