eparst / javasape

Automatically exported from code.google.com/p/javasape
0 stars 0 forks source link

java.net.SocketException: Too many open files #1

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Create huge loop where you call the method - fetchRemoteFile:

svn/  trunk/ src/ java/ javasape/ SapeConnection.java

Try to call 100 000 times, for example. 

What is the expected output? What do you see instead?

I do not expect to get that exception ever. But I get it:

Exception looks like on Linux CentOS:

java.net.SocketException: Too many open files
at java.net.Socket.createImpl(Socket.java:331)
at java.net.Socket.connect(Socket.java:450)

What version of the product are you using? On what operating system?

CentOs, Linux. Java 6.0. Tomcat 5.5.

Please provide any additional information below.

For me, it looks like when we call:

Reader r = new BufferedReader(new 
InputStreamReader(connection.getInputStream(), "UTF-8"));

Below we have to close reader to release all consumed resources.

r.close();

inside the finally statement.

Original issue reported on code.google.com by alexande...@gmail.com on 22 Mar 2011 at 4:48

GoogleCodeExporter commented 9 years ago
The version I used - javasape-0.1.jar.

Original comment by alexande...@gmail.com on 22 Mar 2011 at 4:49

GoogleCodeExporter commented 9 years ago
I wasn't able to reproduce the bug, as you've described (Ubuntu 2.6.35-28/Java 
1.6.0_24).
Maybe 100 000 requests should run in paralel (10 threads, for example)?

However, you way of cleanup seems to me more matching to the design of 
URLConnection.
So I've updated SapeConnection.java and uploaded new jar file.
http://javasape.googlecode.com/files/javasape-0.2-snapshot.jar

Could you please retest?

Original comment by vasyl.stashuk@gmail.com on 23 Mar 2011 at 8:26