When sending a mail trough javamail, a socket to the smtp server is opened. Now, we got the case, that the connection of the mail server went down while the connection was still alive and while javamail was waiting for the server (spam scanning took a few seconds). Therefor the TCP connection was never really closed and the client deadlocked.
So we decided to use javamails timeouts, which works - the client throws an exception after the time specified. However, the tcp connection is NOT correctly closed (netstat -np still shows the connection as "ESTABLISHED"). Only after I call System.gc(), the socket gets closed.
This is a problem, because gc() is guaranteed before any OOM-Exception is thrown, but not before the FD-limit is reached...
Can this be circumvented somehow or is this a bug in javamail?
Affected System: Linux (debian lenny), Sun JDK 1.6.0.20 (with -XXUseSSE=3), javamail 1.4.3