开发者

Javamail does not completely close socket on timeout

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


The exception doesn't cause the connection to be closed, you have to call Transport.close() yourself.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜