Community
Participate
Working Groups
Build Identifier: 7.2.0v20101020 A java.nio.channels.UnresolvedAddressException during a call to HttpClient.send() results in a file descriptor leak which eventually leads to "Too many open files" errors. In a production application, I was seeing the following exceptions which were resulting in file descriptor leaks: java.nio.channels.UnresolvedAddressException at sun.nio.ch.Net.checkAddress(Net.java:30) at sun.nio.ch.SocketChannelImpl.connect(SocketChannelImpl.java:480) at org.eclipse.jetty.client.SelectConnector.startConnection(SelectConnector.java:143) at org.eclipse.jetty.client.HttpDestination.startNewConnection(HttpDestination.java:254) at org.eclipse.jetty.client.HttpDestination.doSend(HttpDestination.java:548) at org.eclipse.jetty.client.HttpDestination.send(HttpDestination.java:489) at org.eclipse.jetty.client.HttpClient.send(HttpClient.java:148) I created a test application that I'll attach which reproduces the problem. While the test application is running use "lsof -p <pid>|wc -l" to see the number of open files for the process. The number of open files will grow with each send() attempt until eventually you get "Too many open files" errors. Reproducible: Always Steps to Reproduce: 1. Run the attached UnresolvedAddressTest 2. Use lsof to see the open files for the process 3. Notice that the number of open files increases with each loop iteration
Created attachment 204035 [details] Test class that reproduces the problem
Fixed. Also changes the fix for bug 358147 to be a single try/catch block for IOException and close the channel.
(In reply to comment #2) > Fixed. Also changes the fix for bug 358147 to be a single try/catch block for > IOException and close the channel. I don't think UnresolvedAddressException is an IOException, so with the latest change it will no longer be caught.
This is a duplicate of https://bugs.eclipse.org/bugs/show_bug.cgi?id=358147
I misread the inheritance hierarchy for the UnresolvedAddressException. Indeed it is not an IOException. I've checked in a fix for that, and will be released for jetty-7.5.3.