solita / clamav-java

Simple ClamAV client for streaming data to clamd server
GNU Lesser General Public License v2.1
106 stars 46 forks source link

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

Closed K-HT closed 6 years ago

K-HT commented 6 years ago

Hello,

I used this clamAV client to scan some files. But after a lot of scanning I get this error : "java.net.SocketException: Too many open files" I suspect the client to not close some Socket or ressources.

Have you an idea?

Thanks

drogin commented 6 years ago

You are welcome to look at the code, it's basically just one small file. I've read through it, and can't find any obvious places where this can happen. All sockets seems to be handled with try-with-resources, so the socket should be auto-closed. The documentation of ByteArrayOutputStream and ByteArrayInputStream says they don't need to be closed. And closing a socket, will close its corresponding inputstream and outputstream.

K-HT commented 6 years ago

Thanks for your reply. I looked at the code.. but, shame on me, I didn't know the try-with-resources instruction. So I suspected that the socket was never closed. After reading documentation, it seems to be good.

I will look on my application to find something wrong. Sorry for the inconvenience.

drogin commented 6 years ago

No worries. Have another look at your application, and if you can't figure it out, I'll have another look. No one's perfect, so it could be a obscure bug related to closing of resources that I havent found.