Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Iseli2019-09-19 05:42:10 +0000
committerStephan Merkli2019-09-20 05:03:15 +0000
commitcce340c6c7ece322f6ab98ea5f44fc4d046f6606 (patch)
tree2d63c10c30ddd5bf1fd267b725f08bb9f130c84e /org.eclipse.scout.rt.mail
parentd56d9d0a447b7e94036d4c8ba2e24d36aae81312 (diff)
downloadorg.eclipse.scout.rt-cce340c6c7ece322f6ab98ea5f44fc4d046f6606.tar.gz
org.eclipse.scout.rt-cce340c6c7ece322f6ab98ea5f44fc4d046f6606.tar.xz
org.eclipse.scout.rt-cce340c6c7ece322f6ab98ea5f44fc4d046f6606.zip
Fix SmtpConnectionPool not reusing connections
SmtpConnectionPool has a feature where it can close connections that are returned to the pool when either a) they reach a maximum lifetime b) they reach a maximum number of messages sent. A bug in the comparison of the supplied values and the actual values (e.g. configured max lifetime and the actual lifetime) caused connections being closed immediately after first use. This is now fixed. Change-Id: I0c6b480ef75ccac5a5b993703eefbc85bf86e1ad Signed-off-by: Michael Iseli <michael.iseli@bsi-software.com> Reviewed-on: https://git.eclipse.org/r/149846 Tested-by: CI Bot Reviewed-by: Stephan Merkli <stephan.merkli@bsi-software.com>
Diffstat (limited to 'org.eclipse.scout.rt.mail')
-rw-r--r--org.eclipse.scout.rt.mail/src/main/java/org/eclipse/scout/rt/mail/smtp/SmtpConnectionPool.java4
1 files changed, 2 insertions, 2 deletions
diff --git a/org.eclipse.scout.rt.mail/src/main/java/org/eclipse/scout/rt/mail/smtp/SmtpConnectionPool.java b/org.eclipse.scout.rt.mail/src/main/java/org/eclipse/scout/rt/mail/smtp/SmtpConnectionPool.java
index 07aae2e386..5ca9a93243 100644
--- a/org.eclipse.scout.rt.mail/src/main/java/org/eclipse/scout/rt/mail/smtp/SmtpConnectionPool.java
+++ b/org.eclipse.scout.rt.mail/src/main/java/org/eclipse/scout/rt/mail/smtp/SmtpConnectionPool.java
@@ -263,11 +263,11 @@ public class SmtpConnectionPool {
protected P_ReuseCheckResult isReuseAllowed(SmtpConnectionPoolEntry smtpConnectionPoolEntry) {
IDateProvider dateProvider = BEANS.get(IDateProvider.class);
- if (dateProvider.currentMillis().getTime() - smtpConnectionPoolEntry.getCreateTime() < m_maxConnectionLifetime) {
+ if (dateProvider.currentMillis().getTime() - smtpConnectionPoolEntry.getCreateTime() >= m_maxConnectionLifetime) {
return new P_ReuseCheckResult(false, "pooled connection reached max lifetime of {}s", m_maxConnectionLifetime / 1000d);
}
int maxMessagesPerConnection = smtpConnectionPoolEntry.getSmtpServerConfig().getMaxMessagesPerConnection();
- if (maxMessagesPerConnection > 0 && smtpConnectionPoolEntry.getMessagesSent() < maxMessagesPerConnection) {
+ if (maxMessagesPerConnection > 0 && smtpConnectionPoolEntry.getMessagesSent() >= maxMessagesPerConnection) {
return new P_ReuseCheckResult(false, "pooled connection reached max messages sent of {}", maxMessagesPerConnection);
}
return new P_ReuseCheckResult(true, null);

Back to the top